Hey everyone! Im trying to load data from a file into three parallel lists, each piece of data is a different data type. Using a split at the "comma", im having trouble trying to load each piece of data in each list. These parallel lists can be like this:
Index rseat index rname index rcost
0 123 0 Saleh 0 20.00
1 124 1 Saleh 1 20.00
2 544 2 Chandra 2 15.00
3 322 3 Quinn 3 15.00
Etc. etc. etc.
This is the code I got so far
Code:Public Class Form1 Dim ticketFile As System.IO.StreamReader Dim rseat As New List(Of Integer) 'list of seat numbers Dim rname As New List(Of String) 'list of ticket holders Dim rcost As New List(Of Double) 'cost of seat Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoad.Click Dim count As Integer = 0 Dim record As String 'this logic tests for file exists before attempting to open it If System.IO.File.Exists(txtFileName.Text) Then 'this statement opens the file and instantiates a file object ticketFile = New System.IO.StreamReader(txtFileName.Text) Do While ticketFile.Peek <> -1 record = ticketFile.ReadLine ProcessRecord(record) count += 1 Loop lblCount.Text = "found " & count.ToString & " reserved seats" Else lblCount.Text = "file not found" End If End Sub Private Sub ProcessRecord(ByVal rec As String) Dim recField() As String 'split will break a long string like rec into an array of 'shorter strings (recfield) using a delimiter like "," recField = Split(rec, ",") rcost = recField(2) rname = recField(1) rseat = recField(0) End Sub




Reply With Quote