danucalovj

VB6 - Open and read file

Dec 11th, 2011
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. Dim sFileText as String
  2. Dim iFileNo as Integer
  3. iFileNo = FreeFile
  4. 'open the file for reading
  5. Open "C:\Test.txt" For Input As #iFileNo
  6. 'change this filename to an existing file! (or run the example below first)
  7. 'read the file until we reach the end
  8. Do While Not EOF(iFileNo)
  9. Input #iFileNo, sFileText
  10. 'show the text (you will probably want to replace this line as appropriate to your program!)
  11. MsgBox sFileText
  12. Loop
  13. 'close the file (if you dont do this, you wont be able to open it again!)
  14. Close #iFileNo
Advertisement
Add Comment
Please, Sign In to add comment