Hi, im having trouble reading in lines of data using arrays and a structure. I believe my main problem is figuring out how to keep track of the lines read in, even if the whole array size isnt used up. Also, To break up each line I am trying to use the split function to seperate spaces, but dont know if im doing so correctly.
1 line of data looks like this:
Doug Blandon 407 202.00 102.00 104.00 105.00 207.00
My code so far:
Public Class Form1
Dim sr As IO.StreamReader = IO.File.OpenText("comiss.txt")
Structure Records
Dim first As String
Dim last As String
Dim ID As Integer
Dim monSales, tuesSales, wedSales, _
thurSales, friSales As Double
End Structure
Private Sub btnClick_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClick.Click
Const MAXARRAY = 39
Dim Records(MAXARRAY) As Records
Dim counter As Integer = 0
Dim split() As String = IO.File.ReadAllLines("comiss.txt")
Dim aline As String
Dim data() As String
Dim lineCounter as String
Do
aline = split(counter)
data = aline.Split(" "c)
lineCounter += 1
With Records(counter)
.first = data(0)
.last = data(1)
.ID = data(2)
.monSales = data(3)
.tuesSales = data(4)
.wedSales = data(5)
.thurSales = data(6)
.friSales = data(7)
End With
counter += 1
lstReport.Items.Add(Records(counter).first) 'Add the rest?
Loop Until counter = lineCounter
End Sub
End Class