VB 文件 最後一行 倒數第二行
发布时间:2020-12-16 22:42:23 所属栏目:大数据 来源:网络整理
导读: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 ' 读入一行数据并将其赋
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 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |