Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
 
TitleOpen a file and read it all quickly
Keywordsfile, read
CategoriesFiles and Directories
 
Open the file for input. Use the Input$ function to read the file into a string.
 
Private Sub cmdOpen_Click()

    On Error GoTo OpenError
    fnum = FreeFile
    Open txtFileName For Input As fnum
    txt = Input$(LOF(fnum), #fnum)
    Close fnum
    txtFileText = txt
    Exit Sub

OpenError:
    MsgBox "Error " & Format$(Err.Number) & _
        " opening file." & vbCrLf & _
        Err.Description
    Exit Sub
End Sub
 
Formatted by Neil Crosby
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated