arrays

layla

Member
Joined
Apr 26, 2005
Messages
21
Programming Experience
Beginner
Can someone please tell me how to read in a file and save it to a dynamic array at the same time? I have the code to read a file and display it on screen, I just need the code to save the contents to an array at the same time. Its a one dimensional dynamic array.

This is the code I have so far that reads in a file and nothing else:
Dim i AsInteger

Dim AllText, LineOfText AsString

OpenFileDialog1.Filter = "text files(*.txt)|*.txt"

OpenFileDialog1.ShowDialog()

If OpenFileDialog1.FileName <> "" Then

Try

FileOpen(2, OpenFileDialog1.FileName, OpenMode.Input)

i = 1


DoUntil EOF(2)

LineOfText = LineInput(2)



If RichTextBox2.Text = "" Then

RichTextBox2.Text = i & ". " & LineOfText & vbCrLf

Else

RichTextBox2.Text = RichTextBox2.Text & i & ". " & LineOfText & vbCrLf

EndIf

i = i + 1

Loop

Catch ex As Exception

RichTextBox2.Text = AllText

RichTextBox2.Select(1, 0)

RichTextBox2.Enabled = True

Finally

FileClose(2)

EndTry
EndIf

EndSub


Thanks to anyone who can help.
 
Top Bottom