下面这段代码不能实现换行,为什么?
Private Sub Command1_Click()
Dim strTmp As String
Open "E:tmp.txt" For Input As #1
While Not EOF(1)
Line Input #1, strTmp
Text1.Text = Text1.Text & chr(13) & chr(10)
Wend
End Sub
Private Sub Command1_Click()
Dim strTmp As String
Open "E:tmp.txt" For Input As #1
While Not EOF(1)
Line Input #1, strTmp
Text1.Text = Text1.Text & chr(13) & chr(10)
Wend
End Sub
Dim strTmp As String
Open "E:tmp.txt" For Input As #1
While Not EOF(1)
Line Input #1, strTmp
Text1.Text = Text1.Text & vbcrlf
Wend
End Sub
你需要设置text1的MultiLine属性为true
再把你的代码加上你所定义的变量strTmp。
Private Sub Command1_Click()
Dim strTmp As String
Open "E:tmp.txt" For Input As #1
While Not EOF(1)
Line Input #1, strTmp
Text1.Text = Text1.Text & strTmp & chr(13) & chr(10)
Wend
End Sub
想请教一下,chr(13) & chr(10)与& vbcrlf有什么区别,谢谢
如楼上所说,把text1的MultiLine属性设为truePrivate Sub Command1_Click()
Dim strTmp As String
Open "E:tmp.txt" For Input As #1
text1.text=""
While Not EOF(1)
Line Input #1, strTmp
Text1.Text = Text1.Text & strTemp & chr(13) & chr(10)
Wend
close #1
End Sub