Private Sub Command1_Click()
Dim R As String, S As Integer, i As Integer
R = UCase(Dir("路径名\*.txt"))
If R = "" Then MsgBox "文本文件不存在!": Exit Sub
S = InStr(R, "B")
If S <如侍毕>0 Then List1.AddItem R
Do
R = UCase(Dir)
S = InStr(R, "B")
If S <>0 Then List1.AddItem R
Loop Until R = ""
End Sub
Private Sub List1_Click()
Dim R As String, i As Integer, S As String
For i = 0 To List1.ListCount
If List1.Selected(i) = True Then
R = List1.List(i)
Exit For
End If
Next i
Open "路谈蔽径名" + R For Input As #1
S = ""
Do While Not EOF(1)
Line Input #1, R
S = S + R
Loop
RichTextBox1.Text = S
End Sub
试渣芹试吧。
第一步:遍历你指定目录下的文件名,然后把他们赋给字符串姿侍数组;Private Sub Command1_Click()
Dim a(6) As String
Dim i As Integer
a(0) = "asgsd.txt"
a(1) = "sggsd.txt"
a(2) = "睁禅agsgshsd.txt"
a(3) = "cggsd.txt"
a(4) = "aaaggsd.txt"
a(5) = "mgsd.txt"
a(6) = "gsd.txt"
Dim name As String
For i = 0 To 6
If (a(i) Like "a*" &".txt") Then
Combo1.AddItem (a(i))
End If
Next
End Sub
'combo1内会列出所有a开头并且.txt后缀的字符串。
第三步:打开文件;
第一步第三部怎么做网上答案一大堆,主要这第二部你模仿迹早吵我做就行了。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)