This is how I did it in VB6, the output to a message box can easily be improved upon. The program is split into two parts. When reading and writing information from a file which you wanted saved for future use, I found that the best way to do this and give you complete control is through an array.
If you look at the first part, I've created it as a function because you can use it for anything once you got the hang of it. Just type 'Call Populate" When you want to use it and it'll write whatever you want to a text file.
There are several key points, firstly the size of the array, strCust(2,3) means two rows and 3 columns big. If you can picture that in your head then you should no problem changing it to fit your needs.
The next point is if you increase the column width you can just copy and paste a bit of code that fills up one column and change the value where it says e.g. intCounter2 = 2, i.e. you created an array like this strCust(2,4), change this to 4 and adjust the source variable for whats going into the array. If you increase the rows, say str(5,2), if you look for the FOR loop and just change it to For intCounter = 0 to 3. Now if you go to the bottom of the function, it begins writing the information to the file, again it's a copy and paste job and change the inCounter2 to equal the new column you maybe adding. Just remember to add a ; sign to the previous statement but leave it out on the last because otherwise it'll write the information to the same line.
Then we look at the second part, this part reads the information back into an array, this allows you manipulate and put the information where you want. I've fed it into a variable using concatenation to turn it into a scoreboard within a message box.
Public Function Populate()
Dim strCust(2, 3) As String
Dim strName As String
Dim intCounter As Integer, intCounter2 As Integer, intAutonumber As Integer
Dim strScore As String
Open "C:/test.txt" For Output As #1
For intCounter = 0 To 1
intCounter2 = 0
intAutonumber = intAutonumber + 1
strCust(intCounter, intCounter2) = intAutonumber
intCounter2 = 1
strName = InputBox("First name?")
strCust(intCounter, intCounter2) = strName
intCounter2 = 2
strScore = InputBox("Please enter score?")
strCust(intCounter, intCounter2) = strScore
Next intCounter
intHolder = intCounter - 1
intCounter = 0
For intCounter = 0 To intHolder
intCounter2 = 0
Write #1, strCust(intCounter, intCounter2);
intCounter2 = 1
Write #1, Tab(12); strCust(intCounter, intCounter2);
intCounter2 = 2
Write #1, Tab(24); strCust(intCounter, intCounter2)
Next intCounter
Close 1
End Function
------------------------------------------------------
Private Sub Command1_Click()
Dim strCust(2, 3) As String, details As String
Dim intCounter As Integer, intCounter2 As Integer
Open "C:/test.txt" For Input As #1
intCounter = 0
intCounter2 = 0
Do While Not EOF(1)
Input #1, details
strCust(intCounter, intCounter2) = details
Scoreholder = (strCust(intCounter, intCounter2))
If intCounter2 = 2 Then
Scoreboard = Scoreboard & " " & Scoreholder & vbCrLf
Else
Scoreboard = Scoreboard & " " & Scoreholder
End If
intCounter2 = intCounter2 + 1
If intCounter2 = 3 Then
intCounter2 = 0
intCounter = intCounter + 1
End If
If intCounter = 3 Then
Exit Do
End If
Loop
Close 1
MsgBox (Scoreboard)
End Sub