1
Private Sub Command4_Click()
Text1.Text = ""CommonDialog1.Filter = "*.txt 文件|*.txt"
CommonDialog1.ShowOpen
Open CommonDialog1.FileName For Input As #1
Do While Not EOF(1) ' 循环至文件尾。
Line Input #1,TextLine ' 读入一行数据并将其赋予某变量。
Text1.Text = TextLine
Loop
Close #1
End Sub
2
Open xxx For Input As #1
s = StrConv(InputB$(LOF(1),#1),vbUnicode)
Close #1
v=split(s,vbcrlf)
msgBox v(ubound(v))
倒數顯示 其实你可以换个思路,先把文件读入到一个数组,倒着来就是从最后一行往上了,看看这个 Dim FileN As String,i As Integer Dim Lines() As String,s as string FileN = "c:\123.txt" Open FileN For Input As #1 '读取文本行数 While Not EOF(1) Line Input #1,s i = i + 1 Wend Close #1 ReDim Lines(i) Open FileN For Input As #1 '读入文本至数组 While Not EOF(1) Line Input #1,Lines(i) i = i + 1 Wend Close #1 For i = UBound(Lines) To 0 Step -1 '倒序输出 Print Lines(i) Next 原文链接:https://www.f2er.com/vb/260573.html