Results 1 to 2 of 2

Thread: Textfile and Textbox

  1. #1

    Thread Starter
    Hyperactive Member Matt-D's Avatar
    Join Date
    Nov 1999
    Location
    Mettmann, Germany
    Posts
    305

    Post

    I know this method to open a textfile into a textbox:
    VB Code:
    1. Filenum = FreeFile
    2.     Open "c:\File1.txt" For Input As Filenum
    3.     T1_DTBANK.Text = Input(LOF(Filenum), Filenum)
    4.     Close Filenum
    My progam loads some paths from five textfiles (each with one line, e.g. "C:\XXXXXX\XXXXXXX.TXT").

    Now my question:
    Is there a way, that there is only one textfile with all this things?
    Is it possile, that I open the textfile,
    so the textbox no. 1 has the text of the first line (of the textfile), the textbox no.2 has the text of the second line, and so on.

    How do I have to modify the code?
    I hope you understant my problem.

    Thanks for some help, Matt
    Last edited by Matt-D; Sep 18th, 2003 at 03:25 PM.

  2. #2
    Lively Member Ishamel's Avatar
    Join Date
    Nov 1999
    Location
    Edinburgh, Scotland
    Posts
    112

    Post

    If I am to understand you correctly, I think you are after something that uses the LINE INPUT syntax. (I have assumed your Text Box controls are part of a control array)

    Code:
    Dim iFreeFile as integer
    
    Dim iControlArrayInstance as Integer
    
    
    iFreeFile = FreeFile
    
    iControlArrayInstance = 0
    
    
    Open "C:\File.txt" For Input As #iFreeFile
        
    Do While Not EOF(iFreeFile)
    
        'Read one whole line at a time
        Line Input #iFreeFile, sMyString
    
        'Place the text in the relevant TextBox (Control Array)
        txtMyTextBoxControlArray(iArrayInstance) = sMyString
        iArrayInstance = iArrayInstance + 1
    Loop
        
    Close #iFreeFile
    The five lines from your txt file should now be in five different text box controls.

    ------------------
    Ishamel
    [email protected]

    How can I tell you I love you when you are sitting on my face?

    [This message has been edited by Ishamel (edited 02-22-2000).]

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