I am writing a program that adds car information including model, manufacturer, year, and vin to a file. This portion of my program works fine. In the second portion of my program I have to access that information by refering to it's VIN number in the text file. I figured the best way to get this to work would be an array. When I run the program I get an error and notice that the information is not getting into the array. Any help would be appreciated.
Here is the code:
'Sets intLines equal to 0
intLines = 0
'Loops through the file to see how many lines there are
Do Until vehicleStreamReader.Peek = -1
strTemp = vehicleStreamReader.ReadLine()
'Adds one to the line count for ever time the loop runs
intLines = intLines + 1
Loop
'Sets intLines equal to 0
intLines = 0
'Loops through the file to see how many lines there are
Do Until vehicleStreamReader.Peek = -1
strTemp = vehicleStreamReader.ReadLine()
'Adds one to the line count for every time the loop runs
intLines = intLines + 1
Loop
'Creates an array for the number of lines, subtract 1 since arrays start at 0
Dim strVehicleInformation(intLines - 1) As String
'Sets intCount equal to 0
intCount = 0
'Adds the lines to the strVehicleInformation array
Do Until vehicleStreamReader.Peek = -1
'Adds the current line to the array
strVehicleInformation(intCount) = vehicleStreamReader.ReadLine()
'Goes to the next line
intCount = intCount + 1
Loop
'sets intIndex2 to 0
intIndex2 = 0
'loop that runs until the statement is true or until it reaches the end of the array
Do Until blnFoundBoolean = True Or intIndex2 = intLines
'If then statement that sees if the selected text of the cb is equal to the information in the array at
'the array position intIndex2
If cbVin.SelectedText = strVehicleInformation(intIndex2) Then
'If there is a match this sets the location
intArrayLocation = intIndex2
'Sets foundboolean to true so the loop will stop running
blnFoundBoolean = True
Else
'If there is no match add one to the Index to search next line of array
intIndex2 = intIndex2 + 1
End If
Loop
'sets intModel to 3 spots behind vin to get model
intModel = intIndex2 - 3
'sets intManufacturer 2 spots behind vin to get manufacturer
intManufacturer = intIndex2 - 2
'sets year 1 spot behind vin to get year
intYear = intIndex2 - 1
'gets model from array and places it in lblModel
lblModel.Text = strVehicleInformation(intModel)
'gets manufacturer from array and places it in lblManufacturer
lblManufacturer.Text = strVehicleInformation(intManufacturer)
'gets Year from array and places it in lblYear
lblYear.Text = strVehicleInformation(intYear)
all variables are delcared. don't laugh if the logic is entirely wrong.
Here is the code:
'Sets intLines equal to 0
intLines = 0
'Loops through the file to see how many lines there are
Do Until vehicleStreamReader.Peek = -1
strTemp = vehicleStreamReader.ReadLine()
'Adds one to the line count for ever time the loop runs
intLines = intLines + 1
Loop
'Sets intLines equal to 0
intLines = 0
'Loops through the file to see how many lines there are
Do Until vehicleStreamReader.Peek = -1
strTemp = vehicleStreamReader.ReadLine()
'Adds one to the line count for every time the loop runs
intLines = intLines + 1
Loop
'Creates an array for the number of lines, subtract 1 since arrays start at 0
Dim strVehicleInformation(intLines - 1) As String
'Sets intCount equal to 0
intCount = 0
'Adds the lines to the strVehicleInformation array
Do Until vehicleStreamReader.Peek = -1
'Adds the current line to the array
strVehicleInformation(intCount) = vehicleStreamReader.ReadLine()
'Goes to the next line
intCount = intCount + 1
Loop
'sets intIndex2 to 0
intIndex2 = 0
'loop that runs until the statement is true or until it reaches the end of the array
Do Until blnFoundBoolean = True Or intIndex2 = intLines
'If then statement that sees if the selected text of the cb is equal to the information in the array at
'the array position intIndex2
If cbVin.SelectedText = strVehicleInformation(intIndex2) Then
'If there is a match this sets the location
intArrayLocation = intIndex2
'Sets foundboolean to true so the loop will stop running
blnFoundBoolean = True
Else
'If there is no match add one to the Index to search next line of array
intIndex2 = intIndex2 + 1
End If
Loop
'sets intModel to 3 spots behind vin to get model
intModel = intIndex2 - 3
'sets intManufacturer 2 spots behind vin to get manufacturer
intManufacturer = intIndex2 - 2
'sets year 1 spot behind vin to get year
intYear = intIndex2 - 1
'gets model from array and places it in lblModel
lblModel.Text = strVehicleInformation(intModel)
'gets manufacturer from array and places it in lblManufacturer
lblManufacturer.Text = strVehicleInformation(intManufacturer)
'gets Year from array and places it in lblYear
lblYear.Text = strVehicleInformation(intYear)
all variables are delcared. don't laugh if the logic is entirely wrong.