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

前端 未结 7 1642
悲哀的现实
悲哀的现实 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:46

    if there is just plain text in the file then you can read in the whole into 1 string variable with the following code :

    Private Sub ReadFile(strFile As String)
      Dim intFile As Integer
      Dim strData As String
      intFile = FreeFile
      Open strFile For Input As #intFile
        strData = Input(LOF(intFile), #intFile)
      Close #intFile
    End Sub
    

    a variable-length string can contain up to approximately 2 billion (2^31) characters

提交回复
热议问题