vb 打开txt文件并显示在一个文本框中
PrivateSubFile1_Click()DimstAsString,fpathAsStringText1.Text=""IfRight(Dir1.Path,1)="...
Private Sub File1_Click()
Dim st As String, fpath As String
Text1.Text = ""
If Right(Dir1.Path, 1) = "\" Then
fpath$ = Dir1.Path & File1.FileName
Else
fpath$ = Dir1.Path & "\" & File1.FileName
End If
Open fpath For Input As #1'个人怀疑这儿错了 但不知道怎么改
Do While EOF(1) '一直执行直到读到文件末尾
Line Input #1, st '每次读取一个整行
Text1.Text = Text1.Text + st + vbCrLf
Loop
Close #1
End Sub 展开
Dim st As String, fpath As String
Text1.Text = ""
If Right(Dir1.Path, 1) = "\" Then
fpath$ = Dir1.Path & File1.FileName
Else
fpath$ = Dir1.Path & "\" & File1.FileName
End If
Open fpath For Input As #1'个人怀疑这儿错了 但不知道怎么改
Do While EOF(1) '一直执行直到读到文件末尾
Line Input #1, st '每次读取一个整行
Text1.Text = Text1.Text + st + vbCrLf
Loop
Close #1
End Sub 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询