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

Thread: Help in VB6

  1. #1
    Join Date
    Jul 2000
    Posts
    1

    Help in VB6

    hi,
    I need to save my final data in a text file,but i cant seem to do it.And also,I cant seem to figure out how to retrieve data from the text box (i.e.,using the open box control).

    It would be great if u guys can help me out on this.

    Thanks


  2. #2
    Join Date
    Feb 2000
    Location
    Kansas
    Posts
    49

    Re: Help in VB6

    Here's a simple and quick explanation for saving data to a file:

    Dim filename as string
    Dim strData as string

    'get data from a text box and input into variable
    'to write to the text file
    strData = Text1.text 'gets the text from a text
    'box named Text1
    filename = "mydoc.txt" 'any valid filename

    Open filename for input as #1
    LineInput#1, strData
    Close #1




    That code will write one line to your text file. If you wish to write more lines at once simply use a Do Loop to write all the lines you wish to write.


    Open filename for input as #1
    Do [condition]
    strData = "new value" 'some new value
    'you could use an array on this line that holds
    'all the lines of text you want to hold e.g.
    'strData = strArray(iCounter) and create an
    'incrementing iCounter (integer) inside the loop
    input#1, strData
    Loop
    Close #1




    Hope this helps you out.


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

Featured