I thought I would start a new thread to clean up a little bit. It's too confusing. I've got code now that takes the first three characters of each line and lists it in a listbox. But...
How do I put each line into an array? The suggestions Edenis suggested in the other thread don't work (Add and ToArray are not members of System.Array)
Any suggestions are appreciated! Here is my code...
VB Code:
Private strIDNumbers As ArrayList() Private intRecordcount As Integer = 0 Private Sub OpenFileButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenFileButton.Click 'determine if customers.txt exists If System.IO.File.Exists("customers.txt") = True Then 'make the property labels visible Me.IDNumberLabel.Visible = True Me.NameLabel.Visible = True Me.CreditLimitLabel.Visible = True Me.BalanceDueLabel.Visible = True 'open the text file Dim objStreamReader As System.IO.StreamReader Dim strLine As String objStreamReader = System.IO.File.OpenText("customers.txt") Do While objStreamReader.Read strLine = objStreamReader.ReadLine Dim strID As String, intLength As Integer intLength = Val(strLine.Length) strID = strLine.Remove(3, (intLength - 3)) Me.IDListBox.Items.Add(strID) intRecordcount = intRecordcount + 1 Loop Me.OpenFileButton.Enabled = False 'customers.txt does not exist, stop Else MessageBox.Show("File does not exist!", "File not found", _ MessageBoxButtons.OK, MessageBoxIcon.Exclamation) End If End Sub




Reply With Quote