VB 文件 最後一行 倒數第二行

VB 文件 最後一行 倒數第二行,第1张

概述1 Private Sub Command4_Click()     Text1.Text = ""     CommonDialog1.Filter = "*.txt 文件|*.txt"     CommonDialog1.ShowOpen         Open CommonDialog1.FileName For Input As #1             Do While Not E

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 总结

以上是内存溢出为你收集整理的VB 文件 最後一行 倒數第二行全部内容,希望文章能够帮你解决VB 文件 最後一行 倒數第二行所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/1289313.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-09
下一篇2022-06-09

发表评论

登录后才能评论

评论列表(0条)

    保存