开发者

VB实现按行读取文本文件的方法

本文实例讲述了VBhttp://www.devze.com实现按行读取文本文件的方法。分享给大家供大家参考。具体如下:

'(general declaration)
Dim nFileNum As Integer, sText As String, sNextLine As String, lLineCount As Long
'==================================
Private Sub Command1_Click()
' Get a free file number
nFileNum = FreeFile
' Open a text file for input. inputbox returns the path to read theAquaLsf file
Open "C:\Documents and Settings\Sudeep\My Documents\3.txt" For Input As nFileNum编程客栈
lLineCount = 1
' Read the contents of the file
Do While Not EOF(nFileNum)
  Line Input #nFileNum, sNextLine
  'do something with it
  'add line numbers to it, inwww.devze.com this 开发者_Js入门case!
  sNextLine = sNextLine & vbCrLf
  sText = sText & sNextLine
Loop
Text1.Tex编程客栈t = sText
' Close the file
Close nFileNum
End Sub

希望本文所述对大家的VB程序设计有所帮助。

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新开发

开发排行榜