05-06-2003, 04:09 PM
How do you read in from a text file on different lines?
And save to different lines?
Textbox1, Textbox2, Textbox3, Textbox4 etc
I want to save Textbox1.Text in a textfile, Textbox2.Text in there to etc
When I load my program, I want string1 to go in Textbox1.text etc
How do you do this?
05-06-2003, 04:11 PM
When saving the file, Print each textbox contents to a separate line.
When reading the file, use Line Input to read into each textbox.
05-13-2003, 03:15 PM
OK I never really fixed this problem so I will try to reexplain my problem:
I have 3 ListBoxs on my form.
2 are of which are HIDDEN
So there is only 1 main ListBox visible.
The aim is, to enter an Email Address in to TextBox 1 and a Nickname into TextBox2, then hit enter.
From here the Email goes to the 1st Hidden ListBox and the Nickname goes into the 2nd ListBox.
Then the Email and the Nickname BOTH go into the Visible ListBox.
[Hidden ListBox 1] - [Hidden ListBox2]
[- - - - - Main Visible ListBox - - - - ]
__TextBox1__ - - - - -__TextBox2__
Now my problem:
Every time I run this program, I have to Re-Enter all my contacts emain and nicknames.
How can I read from numerous lines in a text file to put them in order into the ListBoxes?
05-13-2003, 04:52 PM
Squirm had the Right Idea. You need to learn about Editing files. Here is a quick bit of code showing 1 way you could do it. If none of this makes sense, go find a tutorial somewhere on how to write/read from files Private Sub Command1_Click()
Open filePath For Output As #1
For i = 0 To List1.ListCount - 1
List1.ListIndex = i
Print #1, List1.Text
Print #1, "<--Break-->"
For i = 0 To List2.ListCount - 1
List2.ListIndex = i
Print #1, List2.Text
Private Sub Form_Load()
Dim theBool As Boolean
theBool = False
Open filepath For Input As #1
fileinfo = Input(LOF(1), #1)
myArray = Split(fileinfo, vbCrLf)
For i = 0 To UBound(myArray)
If myArray(i) <> "" Then
If theBool = False Then
If myArray(i) <> "<--Break-->" Then
theBool = True