What I am doing is using a stream reader to read data from a file each line of the file contains 3 parts:
ToolCode,Description,Price
Obviously I am using the "," as the delimiter character
I would like to split up the three parts into three separate arrays. I have a textbox set up where the user inputs a toolcode (must match exactly) and i would like it to display the description and the price in separate textboxes. I know where my problem resides I just can't find anything that tells me how to define the variable properly.
This is the code for the Load Event:
VB Code:
  1. 'Declare variables and constants
  2.         Dim strFileName As String
  3.         Dim strLine As String
  4.         Dim chrDelimiter As Char
  5.  
  6.         'Declare delimiter character
  7.         chrDelimiter = ","
  8.  
  9.         strFileName = CurDir() & "\tools.txt"
  10.         Dim srdReadFile As System.IO.StreamReader = New System.IO.StreamReader(strFileName)
  11.  
  12.         Do Until srdReadFile.peek = -1
  13.             ReDim Preserve strToolCode(intNumTools) = strFields(0) 'I realize this is illegal but how do I define this so that I can display it later?
  14.             ReDim Preserve strDescription(intNumTools)
  15.             ReDim Preserve decPrices(intNumTools)
  16.             strLine = srdReadFile.ReadLine
  17.             strFields = strLine.Split(chrDelimiter)
  18.             intNumTools = intNumTools + 1
  19.         Loop
  20.  
  21.         'Close file
  22.         FileClose()

This is the search button code:
VB Code:
  1. 'Declare variables
  2.         Dim intCounter As Integer
  3.         Dim intResults As Integer
  4.         Dim strFindToolCode As String
  5.         Dim blnFound As Boolean
  6.         Dim intPartIndex As Integer
  7.         Dim intNumRecords As Integer
  8.  
  9.         strFindToolCode = CStr(txtToolCode.Text)
  10.         blnFound = False
  11.  
  12.         For intCounter = 0 To intNumTools - 1
  13.             If UCase(strFindToolCode) = UCase(strToolCode(intCounter)) Then
  14.                 blnFound = True
  15.                 intPartIndex = intCounter
  16.                 Exit For
  17.             End If
  18.         Next
  19.  
  20.         If blnFound Then
  21.             txtDesc.Text = strToolCode(intPartIndex)
  22.         Else
  23.             MsgBox("Part not found", MsgBoxStyle.Exclamation, "Harry's Hardware")
  24.             Exit Sub
  25.         End If

My 3 textboxes are txtToolCode, txtDesc, and txtPrice