dim strExpData as string strExpData = "name:aaaa" & vbCrLf & "email:bbbb" & vbCrLf & "addr:cccc" Open d:\lipeng.txt For Output As #1 Print #1, strExpData Close #1然后再用你的代码读读看。
Dim TextLine Open "TESTFILE" For Input As #1 ' 開啟檔案。 Do While Not EOF(1) ' 執行迴圈直到檔尾為止。 Line Input #1, TextLine ' 讀入一行資料並將之指定給變數。 text1.text=text1.text+textline+vbcrlf 'text1為文本框 Loop Close #1 ' 關閉檔案。
要用vbCrLf字符回车换行
1。你的纪录超出是因为你读取的时候是以行来读取的,而不是域。
你需要使用命令:input #文件名,变量 来实现你的要求2。换行的代码很容易。
textbox.text=textbox.text & vbcrlf
strExpData = "name:aaaa" & vbCrLf & "email:bbbb" & vbCrLf & "addr:cccc"
Open d:\lipeng.txt For Output As #1
Print #1, strExpData
Close #1然后再用你的代码读读看。
Open "TESTFILE" For Input As #1 ' 開啟檔案。
Do While Not EOF(1) ' 執行迴圈直到檔尾為止。
Line Input #1, TextLine ' 讀入一行資料並將之指定給變數。
text1.text=text1.text+textline+vbcrlf 'text1為文本框
Loop
Close #1 ' 關閉檔案。