我已经有一段代码:
Private Sub Command1_Click()
Dim r As String, s() As String, i As Long, x As Long
Open "123.txt" For Input As #1
Do Until EOF(1)
Line Input #1, r
If Len(r) > 0 Then
s = Split(r, ",")
If s(0) = Text1.Text Then
Form1.Label1.Caption = s(0)
Form1.Label2.Caption = s(1)
Form1.Label3.Caption = s(2)
Form1.List1.Clear
x = 0
For i = 3 To Val(s(2)) + 2
x = x + 1
Form1.List1.AddItem x & "." & "20" & Mid(s(i), 1, 2) & "." & Mid(s(i), 3, 2) & "." & Mid(s(i), 5, 2)
Next i
Unload Me
Exit Do
End If
End If
Loop
Close #1
End Sub
在哪里加什么代码能让它如果文件已经读完,且没有匹配的值的话msgbox "无此名单"并退出循环
要每一行都行,有的除了第一行以外都会出错
Private Sub Command1_Click()
Dim r As String, s() As String, i As Long, x As Long
Open "123.txt" For Input As #1
Do Until EOF(1)
Line Input #1, r
If Len(r) > 0 Then
s = Split(r, ",")
If s(0) = Text1.Text Then
Form1.Label1.Caption = s(0)
Form1.Label2.Caption = s(1)
Form1.Label3.Caption = s(2)
Form1.List1.Clear
x = 0
For i = 3 To Val(s(2)) + 2
x = x + 1
Form1.List1.AddItem x & "." & "20" & Mid(s(i), 1, 2) & "." & Mid(s(i), 3, 2) & "." & Mid(s(i), 5, 2)
Next i
Unload Me
Exit Do
End If
End If
Loop
Close #1
End Sub
在哪里加什么代码能让它如果文件已经读完,且没有匹配的值的话msgbox "无此名单"并退出循环
要每一行都行,有的除了第一行以外都会出错
