VB Code:
'Declare variables and constants
Dim strFileName As String
Dim strLine As String
Dim chrDelimiter As Char
'Declare delimiter character
chrDelimiter = ","
strFileName = CurDir() & "\tools.txt"
Dim srdReadFile As System.IO.StreamReader = New System.IO.StreamReader(strFileName)
Do Until srdReadFile.peek = -1
ReDim Preserve strToolCode(intNumTools) = strFields(0) 'I realize this is illegal but how do I define this so that I can display it later?
ReDim Preserve strDescription(intNumTools)
ReDim Preserve decPrices(intNumTools)
strLine = srdReadFile.ReadLine
strFields = strLine.Split(chrDelimiter)
intNumTools = intNumTools + 1
Loop
'Close file
FileClose()
VB Code:
'Declare variables
Dim intCounter As Integer
Dim intResults As Integer
Dim strFindToolCode As String
Dim blnFound As Boolean
Dim intPartIndex As Integer
Dim intNumRecords As Integer
strFindToolCode = CStr(txtToolCode.Text)
blnFound = False
For intCounter = 0 To intNumTools - 1
If UCase(strFindToolCode) = UCase(strToolCode(intCounter)) Then
blnFound = True
intPartIndex = intCounter
Exit For
End If
Next
If blnFound Then
txtDesc.Text = strToolCode(intPartIndex)
Else
MsgBox("Part not found", MsgBoxStyle.Exclamation, "Harry's Hardware")
Exit Sub
End If