Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saving a lot of text files in a single file and load different lines!! 1

Status
Not open for further replies.

SurvivorTiger

Programmer
Jul 9, 2002
265
US
Hi everyone
I want to know how I can save bounch of texts from different text boxes into a single txt file(or any other format) and have it load for example the 10th line of the text in a text box and load 5th line in a different text box.

I tried somethings that i found in MSDN help, but it really didn't help!!
 
To save use:

Code:
Dim dateiname As String, dateinr As Integer
dateiname = App.Path & "\filename.txt"
dateinr = FreeFile
Open dateiname For Output As dateinr
Print #dateinr, (Text1.Text & vbCrLf & Text2.text & vbCrLf & Text3.text & vbCrLf & Text4.text)
Close dateinr

To access certain lines use:

Code:
Dim LinesFromFile As New Collection
Open App.Path & "\filename.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, MyString
LinesFromFile.Add MyString
Loop
Close #1 ' Close file.
Label1.Caption = LinesFromFile(1)
Label2.Caption = LinesFromFile(2)
Label3.Caption = LinesFromFile(3)
Label4.Caption = LinesFromFile(4)


Hope this helps,
Jonathon. It's incredible to think that before computers were invented we had to mess things up ourselves!
 
Thanks for helping, It really worked except that you forgot to have "Dim MyString As String".
Thanks again!!
 
The post above was written by me (Survivortiger), i was accidently logged in with my friend's screen name who had signed in before me!!

Thanks for helping, It really worked except that you forgot to have "Dim MyString As String".
Thanks again!!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top