vb中,怎样使txt文本中的内容一行一行显示在文本框中?

1 525.500
1 2 -5
2 3 0.6 0.0880
3 4 -3.901 0.0977
怎么在文本框中按上面的格式显示

把文本框的MultiLine属性设为True,ScrollBars属性设为2或3,然后:

Open "123.txt" For Binary As #1
Text1.Text = Input(LOF(1), #1)
Close #1
温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-05-12
直接用文本模式读取txt文件就可以啊,
格式是和你文件的格式一样的。
Dim Str$
Open "D:\1.txt" For Input As #1 '假设文件在D:\1.txt
Str = Input$(LOF(1), #1)
Close #1
Text1.Text=Str '假设文本框为Text1
第2个回答  2012-05-12
把Text1的MultiLine属性设置为True
把你的文本文件命名为a.txt,保存在你本程序同一文件夹。
Private Sub Command1_Click()
Dim Fn As Long
Dim sIn As String
Fn = FreeFile
Open App.Path & "\a.txt" For Binary As #Fn
sIn = Input$(LOF(Fn), #Fn)
Close #Fn
Text1.Text = sIn
End Sub
第3个回答  2012-05-12
在读取的字符后面加个chr(13)和一个vbctrf.不好意思后面这个记不住了,貌似不加直接写到Txtbox也可以,把楼上说的设好
第4个回答  2012-05-11
文本框有个属性muteline好像是,具体忘了
相似回答