24小时热门版块排行榜    

北京石油化工学院2026年研究生招生接收调剂公告
查看: 1279  |  回复: 13

chelator

木虫 (小有名气)

代码如下
Dim a() As Single
Dim LineNum  As Long

Private Sub Command1_Click()

Dim i, j, k As Long

Dim TextLine As String
Dim EachText() As String
LineNum = 0
Open App.Path & "\data.txt" For Input As #1
Do While Not EOF(1)
   Line Input #1, TextLine
   LineNum = LineNum + 1
Loop
Close #1

ReDim a(LineNum - 1, 2)

Open App.Path & "\data.txt" For Input As #1

i = 0
Do While Not EOF(1)
    Line Input #1, TextLine
    EachText = Split(TextLine, " ", -1, vbTextCompare)
    k = 0
    For j = 0 To UBound(EachText)
        If EachText(j) <> "" Then
            a(i, k) = CSng(EachText(j))
            k = k + 1
        End If
    Next
   i = i + 1
Loop
Close #1

Command2.Enabled = True

MsgBox ("读取数据成功"
End Sub

Private Sub Command2_Click()
Dim Xmax, Xmin, Ymax, Ymin, Zvalue As Single
Dim Count As Long

If IsNumeric(TextXMax.Text) And IsNumeric(TextXMin.Text) And _
IsNumeric(TextYMax.Text) And IsNumeric(TextYMin.Text) And _
IsNumeric(TextZ.Text) Then
    Xmax = CSng(TextXMax.Text)
    Xmin = CSng(TextXMin.Text)
    Ymax = CSng(TextYMax.Text)
    Ymin = CSng(TextYMin.Text)
    Zvalue = CSng(TextZ.Text)
   
    If Xmax < Xmin Then
        MsgBox ("X最大最小值有误"
        Exit Sub
    End If
   
    If Ymax < Ymin Then
        MsgBox ("Y最大最小值有误"
        Exit Sub
    End If
   
   
    Open App.Path & "\result.txt" For Output As #1
        For i = 0 To LineNum - 1
            If a(i, 0) <= Xmax And a(i, 0) >= Xmin And _
                a(i, 1) <= Ymax And a(i, 1) >= Ymin And _
                a(i, 2) <> Z Then
                Print #1, a(1, 0) & "  " & a(i, 1) & "  " & a(i, 2)
                Count = Count + 1
            End If
        Next
    Close #1
   
    MsgBox ("有" & CStr(Count) & "行输出"
Else
    MsgBox ("请输入数字"
End If
End Sub
11楼2013-04-11 09:31:38
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

chelator

木虫 (小有名气)

其中
Xmax = CSng(TextXMax.Text)
    Xmin = CSng(TextXMin.Text)
    Ymax = CSng(TextYMax.Text)
    Ymin = CSng(TextYMin.Text)
    Zvalue = CSng(TextZ.Text)

TextXMax 是你的TextBox,我重新命名了。
12楼2013-04-11 09:33:27
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

chelator

木虫 (小有名气)

错误数据的行号

1771
2158
3453
4806
5256
5446
8162
8549
9844
12091
12478
13773
13楼2013-04-11 09:33:57
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

zjzc511

银虫 (小有名气)

代码如下
Dim a() As Single
Dim LineNum  As Long
Private Sub Command1_Click()
Dim i, j, k As Long
Dim TextLine As String
Dim EachText() As String
LineNum = 0
Open App.Path & "\data.txt" For Input As #1
Do While Not EOF(1)
   Line Input #1, TextLine
   LineNum = LineNum + 1
Loop
Close #1
ReDim a(LineNum - 1, 2)
Open App.Path & "\data.txt" For Input As #1
i = 0
Do While Not EOF(1)
    Line Input #1, TextLine
    EachText = Split(TextLine, " ", -1, vbTextCompare)
    k = 0
    For j = 0 To UBound(EachText)
        If EachText(j) <> "" Then
            a(i, k) = CSng(EachText(j))
            k = k + 1
        End If
    Next
   i = i + 1
Loop
Close #1
Command2.Enabled = True
MsgBox ("读取数据成功"
End Sub
Private Sub Command2_Click()
Dim Xmax, Xmin, Ymax, Ymin, Zvalue As Single
Dim Count As Long
If IsNumeric(TextXMax.Text) And IsNumeric(TextXMin.Text) And _
IsNumeric(TextYMax.Text) And IsNumeric(TextYMin.Text) And _
IsNumeric(TextZ.Text) Then
    Xmax = CSng(TextXMax.Text)
    Xmin = CSng(TextXMin.Text)
    Ymax = CSng(TextYMax.Text)
    Ymin = CSng(TextYMin.Text)
    Zvalue = CSng(TextZ.Text)
   
    If Xmax < Xmin Then
        MsgBox ("X最大最小值有误"
        Exit Sub
    End If
   
    If Ymax < Ymin Then
        MsgBox ("Y最大最小值有误"
        Exit Sub
    End If
   
   
    Open App.Path & "\result.txt" For Output As #1
        For i = 0 To LineNum - 1
            If a(i, 0) <= Xmax And a(i, 0) >= Xmin And _
                a(i, 1) <= Ymax And a(i, 1) >= Ymin And _
                a(i, 2) <> Z Then
                Print #1, a(1, 0) & "  " & a(i, 1) & "  " & a(i, 2)
                Count = Count + 1
            End If
        Next
    Close #1
   
    MsgBox ("有" & CStr(Count) & "行输出"
Else
    MsgBox ("请输入数字"
End If
End Sub
23
14楼2014-05-31 21:06:44
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 huzijun888 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 272分求调剂 +4 wangyile2233 2026-04-02 4/200 2026-04-05 22:21 by 286640313
[考研] 找调剂 +10 楚乔乔 2026-04-01 10/500 2026-04-05 22:19 by syh9288
[考研] 一志愿南昌大学,085600,344分求调剂 +6 调剂上岸玘 2026-04-05 6/300 2026-04-05 22:11 by 789风
[考研] 材料专硕322分 +10 哈哈哈吼吼吼哈 2026-04-04 10/500 2026-04-05 21:22 by 学员8dgXkO
[考研] 本科211,293分请求调剂 +8 莲菜就是藕吧 2026-04-03 9/450 2026-04-05 19:12 by 蓝云思雨
[考研] 275求调剂 +16 waltzh 2026-04-01 16/800 2026-04-05 17:14 by Hdyxbekcb
[考研] 323分(计算机视觉和大模型项目)能直接上手 +3 chaoxiicy 2026-04-01 3/150 2026-04-05 00:50 by chongya
[考研] 材料调剂 +15 一样YWY 2026-04-01 15/750 2026-04-04 22:23 by hemengdong
[考研] 可跨专业调剂 +3 周的得地 2026-04-04 6/300 2026-04-04 22:21 by barlinike
[考研] 0835学硕299求调剂 08大类可接受 +5 useryy 2026-04-03 5/250 2026-04-04 20:07 by 蓝云思雨
[考研] 265求调剂 +17 林深温澜 2026-04-01 20/1000 2026-04-04 01:09 by userper
[考研] 一志愿重庆大学085404,总分314分,求调剂 +4 zf83hn 2026-04-03 4/200 2026-04-03 21:25 by 啵啵啵0119
[考研] 求调剂不挑专业 +3 xrh030412 2026-04-01 3/150 2026-04-03 14:40 by 氮气气气
[考研] 312求调剂 +4 赊月色 2026-04-02 5/250 2026-04-03 08:21 by fangshan711
[考研] 能源动力 调剂 +3 不破不立0 2026-04-02 3/150 2026-04-02 12:46 by ffffjjjj
[考研] 08工科,295,接受跨专业调剂 +6 lmnlzy 2026-03-31 6/300 2026-04-01 11:02 by 逆水乘风
[考研] 0710生物学求调剂! +6 叙述文 2026-03-31 6/300 2026-04-01 09:39 by JourneyLucky
[考研] 一志愿北京科技大学085601材料工程英一数二初试总分335求调剂 +5 双马尾痞老板2 2026-03-31 5/250 2026-04-01 09:04 by oooqiao
[考研] 085601 329分调剂 +6 yzsa12 2026-03-31 6/300 2026-03-31 15:23 by yanflower7133
[考研] 吉大生物学326分求调剂 +3 sunnyupup 2026-03-31 3/150 2026-03-31 09:28 by longlotian
信息提示
请填处理意见