How can I read data from a text file using VB6?

前端 未结 7 1646
悲哀的现实
悲哀的现实 2020-12-06 07:22

I need to read data from text files and use the same in my application. Im using VB 6.0. What commands do I use? Some Sample code would be highly appreciated.

7条回答
  •  不思量自难忘°
    2020-12-06 07:49

    Here is the code for that

    Function ReadFileToText(filePath)
    
       Dim objFile, objText, text
    
       Set objFile = CreateObject("Scripting.FileSystemObject")
       Set objText = objFile.OpenTextFile(filePath)
    
       text = objText.ReadAll
       objText.Close
    
       Set objText = Nothing
       Set objFile = Nothing
    
       ReadFileToText = text
    
    End Function
    

    More details you can check http://smartreferences.blogspot.in

提交回复
热议问题