Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. How to read a text file in VB 6

How to read a text file in VB 6

Scheduled Pinned Locked Moved Visual Basic
tutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    naeemnimi
    wrote on last edited by
    #1

    Hello, Can any body tell me how to read a text file in visual basic 6.The file contains the data not more then 2k. Thanks in advance,

    J 1 Reply Last reply
    0
    • N naeemnimi

      Hello, Can any body tell me how to read a text file in visual basic 6.The file contains the data not more then 2k. Thanks in advance,

      J Offline
      J Offline
      Joshua Quick
      wrote on last edited by
      #2

      Public Function ReadTextFile(sFileName As String) As String Dim iFileNum As Integer Dim bFileOpen As Boolean ' Activate error trapping. On Error GoTo Catch ' Read text file. ReadTextFile = "" iFileNum = FreeFile Open sFileName For Input Access Read As #iFileNum bFileOpen = True ReadTextFile = Input(LOF(iFileNum), iFileNum) Close #iFileNum bFileOpen = False Exit Function Catch: ' An error occurred. This will happen if file was not found. If bFileOpen Then Close #iFileNum End Function Public Sub Test() Dim sText As String sText = ReadTextFile("c:\MyPath\MyFile.txt") End Sub -- modified at 14:07 Monday 14th November, 2005

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups