problem working with text files

massacre

New member
Joined
Aug 22, 2005
Messages
3
Programming Experience
Beginner
hi,
was tring to do some basic file retrival stuff the other day..
well here it goes..
im trying to add the text box fields, from a form to a text file, lets say a student form.
so the student details of one student gets stored as one line in the text file
ie

1001,Mark,18,St.Louis College,Marketing

and the next student details below this line

1002,Joe,19,St.Antony,Science

Please advice me as to how to do this..
I've added the text fields in the text file like the above example.
The problem arises in retrieving the fields..

How do I use arrays for retrieving the particular detail of the student.

I haven't written any particular code for this as nothing was working out..
and didnt know how to go about it..
Please take time and advice.
Any help appreciated

Thanks
 
for retrieving from a text file you must follow these simple steps:-

Dim obj As New System.IO.FileStream("<filename entered here with path>", IO.FileMode.Open)

Dim objreader As New System.IO.StreamReader(obj)

Dim str As String = objreader.ReadLine

Dim inum As Integer

Dim arr(inum) As String

While Not str Is Nothing

ReDim Preserve arr(inum)

arr(inum) = str

str = objreader.ReadLine

inum += 1

End While

objreader.Close()

obj.Close()

Dim readstring As String

For Each readstring In arr

MessageBox.Show(readstring)

Next

 
Back
Top