dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: read a file????

  1. #1
    Join Date
    Aug 2002
    Location
    paris
    Posts
    136

    read a file????

    i have a request SQL in a text file, and with the name of the file, i want to read the request, how can i proceed?

  2. #2
    Join Date
    Jun 2002
    Location
    Lyman ME - USA | Oneonta NY - USA
    Posts
    399
    there are plenty of posts that cover this sort of thing so you can search the archives for something about this...hope it helps

    - nc
    "In a world without walls and barriers, what need is there for windows and gates!" - a mac ad
    "What was the best thing before sliced bread and when did sliced bread go out of existence?" - me
    "Software is like sex, it's better when it's free." - Linus Torvalds <- gotten from Andreas Masur


    Live Penguine! - Tux the linux mascot
    Vivez le penguine!, ¡Viva en penguine!, Lang lebe der Pinguin!, Viva no penguine!, Viva sul penguine!

  3. #3
    Join Date
    Sep 2001
    Location
    Québec, Canada
    Posts
    1,923
    There is other method (like with OPEN as RANDOM for READ 0, bu tthat one works well, it's with the FileSystemObject

    Code:
        'Add a reference to Microsoft Scripting Runtime
        Dim fso As FileSystemObject
        Set fso = New FileSystemObject
        Dim objFile As File
        
        'Get the file wanted
        Set objFile = fso.GetFile("C:\boot.ini")
        
        Dim objTextStream As TextStream
        
        'Use the TextStream Object to retrieve text
        Set objTextStream = objFile.OpenAsTextStream(ForReading)
        
        'Read ALL the files
        MsgBox objTextStream.ReadAll
        
        'read a line
        'objTextstream.ReadLine
        
        'Destroy objects
        Set objTextStream = Nothing
        Set objFile = Nothing
        Set fso = Nothing
    JeffB - hope it helps

  4. #4
    Join Date
    Aug 2002
    Location
    paris
    Posts
    136
    when i compile your code, i have this error:

    non defined type for filesystemobject...

  5. #5
    Join Date
    Sep 2001
    Location
    Montreal Canada
    Posts
    1,080
    You have to add a reference to the microsoft runtime script.
    Nicolas Bohemier

  6. #6
    Join Date
    Aug 2002
    Location
    paris
    Posts
    136
    and how can i do that? ;-)

  7. #7
    Join Date
    Sep 2001
    Location
    Québec, Canada
    Posts
    1,923
    Guess you have French version, in VB6, go there:

    Projects -> Références

    Chose, in the list, Microsoft Scripting Runtime (coche la case)

    If not there, try to find the file "scrrun.dll"

    JeffB -hope it helps

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)