Results 1 to 4 of 4

Thread: An expert required

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2000
    Posts
    52
    How do i alter this code to read the entire txt fileinto my text box without going through each Line input command.
    Is there a do EOF for this sort of thing?


    Dim intFile As Integer
    Dim strText As String



    'String Loader
    intFile = FreeFile

    Open "C:\Test.txt" For Input As #intFile
    Line Input #1, strText ' Get text from line 1
    Text1.Text = strText
    Line Input #1, strText
    text2.Text = strText ' Get text from line 2
    ' repeat process for 3rd line 4th and so on...
    Close intFile


    Any tips as always are appreciated.

    M.

  2. #2
    New Member
    Join Date
    Jun 2000
    Location
    Chennai,India
    Posts
    7

    try this

    /** let sFile denote the path where ur file exists **/

    Open sFile For Input As InFile
    While Not EOF(InFile)
    Line Input #InFile, NextStatement
    wend

    /** Here NextStatement is a variable storing the line. Now put the textboxes in an array ,say txtStatement.**/

    so the code becomes ..

    Open sFile For Input As InFile
    While Not EOF(InFile)
    Line Input #InFile, NextStatement
    txtStatement(i).text = NextStatement
    i = i + 1
    wend

    If ur not satisfied with the reply pls inform me.
    !@#$%

  3. #3
    Guest
    Dim intFile As Integer
    Dim strText As String
    intFile = FreeFile
    Open "C:\Test.txt" For Input As #intFile
    strText = Input(LOF(1), 1)
    Close #intFile

  4. #4
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    'Open a file in binary mode and read into a textbox or string
    
        Dim sHolder As String
        Dim intNum As Integer
        Dim sFileName As String
        
        'open for binary and read
        sFileName = "C:\My Documents\MyFile.txt"
        intNum = FreeFile
        
        Open sFileName For Binary As intNum
          sHolder = Space(LOF(1))
          Get #1, , sHolder
        Close intNum
        
        'assign the text to a textbox
         Text1 = sHolder    ' for a string (strString = sholder)
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

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