propagandhi
Member
- Joined
- Feb 20, 2005
- Messages
- 18
- Programming Experience
- Beginner
Alright everybody. I have to write a program which writes the store number, location, and store manager to a sequential access file. Im having no problem with this, but the program also has to be able to display a record based on the store number. When I run the program, i receive no errors but the corresponding record does nto display. Here is my code if you think you can help me.
Private Sub btnFind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFind.Click
Dim intIndexofFirstPound As Integer
Dim intIndexofSecondPound As Integer
Dim strRecord As String
Dim strNumber As String
Dim strNumber1 As String
Dim strState As String
Dim strManager As String
Dim sreStreamReader As IO.StreamReader
If IO.File.Exists("c:\Record.text") Then
sreStreamReader = IO.File.OpenText("c:\Record.txt")
strRecord = sreStreamReader.ReadLine()
'Find the index of the first pound sign
intIndexofFirstPound = strRecord.IndexOf("#")
'Pull off the store number starting at index 0 for a length
'of the index of the first pound sign index
strNumber = strRecord.Substring(0, intIndexofFirstPound)
'Determine the index of the second pound sign by starting at one 'position greater than the index of the first pound sign and
'and searching for the second pound sign from that point
intIndexofSecondPound = strRecord.IndexOf("#", intIndexofFirstPound + 1)
'Pull off the state by starting at one more than the index of the
'first pound sign for a length of the second pound sign index minus
'the first pound sign index minus 1
strState = strRecord.Substring(intIndexofFirstPound + 1, intIndexofSecondPound - intIndexofFirstPound - 1)
'Pull off the manager name by starting at one more than the index of
'the second pound sign
strManager = strRecord.Substring(intIndexofSecondPound + 1)
strNumber1 = txtStore.Text
If strNumber = strNumber1 Then
lb1.Items.Add(strNumber & strState & strManager)
sreStreamReader.Close()
End If
End If
End Sub
Private Sub btnFind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFind.Click
Dim intIndexofFirstPound As Integer
Dim intIndexofSecondPound As Integer
Dim strRecord As String
Dim strNumber As String
Dim strNumber1 As String
Dim strState As String
Dim strManager As String
Dim sreStreamReader As IO.StreamReader
If IO.File.Exists("c:\Record.text") Then
sreStreamReader = IO.File.OpenText("c:\Record.txt")
strRecord = sreStreamReader.ReadLine()
'Find the index of the first pound sign
intIndexofFirstPound = strRecord.IndexOf("#")
'Pull off the store number starting at index 0 for a length
'of the index of the first pound sign index
strNumber = strRecord.Substring(0, intIndexofFirstPound)
'Determine the index of the second pound sign by starting at one 'position greater than the index of the first pound sign and
'and searching for the second pound sign from that point
intIndexofSecondPound = strRecord.IndexOf("#", intIndexofFirstPound + 1)
'Pull off the state by starting at one more than the index of the
'first pound sign for a length of the second pound sign index minus
'the first pound sign index minus 1
strState = strRecord.Substring(intIndexofFirstPound + 1, intIndexofSecondPound - intIndexofFirstPound - 1)
'Pull off the manager name by starting at one more than the index of
'the second pound sign
strManager = strRecord.Substring(intIndexofSecondPound + 1)
strNumber1 = txtStore.Text
If strNumber = strNumber1 Then
lb1.Items.Add(strNumber & strState & strManager)
sreStreamReader.Close()
End If
End If
End Sub