vb读取txt文件
我想用vb读取txt文件,文件里面只有一行。将读取出来的内容赋值给TextBox。
求大神帮忙
[解决办法]
Private Sub Command1_Click()
Open "F:\1.txt" For Input As #1
Line Input #1, textline
Text1.Text = textline
Close #1
End Sub
[解决办法]
哪要是读取全部呢??怎么写?
[解决办法]
msdn上有例子,很详细的........
[解决办法]
本帖最后由 bcrun 于 2013-09-11 11:47:56 编辑
Private Sub cmd_Click()
Dim fileName As String
Dim fileNo As Integer
Dim fline As String
Dim strAll As String
fileNo = FreeFile()
Open "C:\1.txt" For Input As fileNo
Do While Not EOF(fileNo )
Line Input #fileNo , fline
strAll = strAll + fline
Loop
Close fileNo
text1.text= strAll
End Sub