Results 1 to 5 of 5

Thread: input statement..for complete txt file

  1. #1

    Thread Starter
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946
    using fso I can read a file into a textbox like soText1.Text = Input(LOF(1), 1)
    if I want to read a complete text file
    and store it in a var how is it done
    in regular read vb looks for a #(FileNumber)
    so it won't accept myVar = input(lof(Filenumber),myVar)
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Open your file with a filenumber first then

    Code:
    filenumber=freefile
    Open yourfile for binary as filenumber
    ...your code
    close filenumber
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3

    Thread Starter
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946
    doesn't accept this

    input(lof(Filenumber),myVar)


    how do I read the entire file inot myVar

    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Hmmm, well you can do it this way
    Code:
    Property Get File(Filename As String) As String
        Dim fnum As Byte
        fnum = FreeFile
        Open Filename For Binary As fnum
            File = Space(LOF(fnum))
            Get #fnum, , File
        Close fnum
    End Property
    Code:
    myVar=file(myfile)
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5
    Fanatic Member RealisticGraphics's Avatar
    Join Date
    Jul 1999
    Location
    Arkansas
    Posts
    655

    Wink

    Use the following function:

    Code:
    Open "C:\MyFile.txt" For Input As #1
        Do Until EOF(1)
        Line Input #1, tString
            Text1.Text = Text1.Text & tString
        Loop
    Close #1
    www.RealisticGraphics.net

    Running VS.Net Enterprise & VB 6

    Other Languages: JavaScript, VBScript, VBA, HTML, CSS, ASP, SQL, XML

    MSN Messenger: kmsheff

Posting Permissions

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



Click Here to Expand Forum to Full Width