Results 1 to 6 of 6

Thread: Quick Question, Please Answer quickly.. very simple

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2000
    Posts
    99
    I want to import a .txt file into a TextBox, how???

    Open C:\text.txt For Input As #1
    Line Input #1, Form1.Text1.Text
    Close #1

    Like that?

    Thanks
    ___________________________
    Chris

  2. #2
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    Code:
    Dim Line As String
    
    Open C:\text.txt For Input As #1 
        Do
            Line Input #1, Line
            Form1.Text1.Text = Form1.Text1.Text & vbcrlf & Line
        Loop Until EOF(1)
    Close #1

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jun 2000
    Posts
    99
    Uhm, actually oetje, that code didnt work when there were lines in the text file.

    I.e.

    Blah1Blah1Blah1

    Blah2Blah2Blah2

    Would be displayed as:

    Blah1Blah1Blah1||Blah2Blah2Blah2
    ___________________________
    Chris

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Set the Text Box's Multiline property to True.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

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

    <?>

    Code:
    'read the complete file instead of line by line
    'faster and cleaner
    
    Option Explicit
    
    Private Sub Command1_Click()
    
        Dim sfile As String, intNum As Integer
        intNum = FreeFile
        sfile = "C:\my Documents\myfile.txt"
        
        Open sfile For Input As intNum
           Text1 = StrConv(InputB(LOF(intNum), intNum), vbUnicode)
         Close intNum
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  6. #6
    Guest
    Code:
    Open "MyFile.txt" For Input As #1
    Text1 = Input(LOF(1), 1)
    Close #1

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