I am trying to make it read from the text file. the items from the text should be in an array. Then when the user types in the Abbreviation text box 2 letters it should try to find the state. Same for the State box to find the abbreviation. When I compile it, it tells me I need to declare "NEW" in my if statement
Code:
If .stateText.Text.ToUpper.Trim = USstate(indexInteger).stateNameString.ToUpper.Trim Then
full sub below
Thanks for any comment or suggestions in advance
Code:
Private Sub LookUpButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LookUpButton.Click
Dim indexInteger As Integer
Dim foundBoolean As Boolean
With Me
If .AbbreviationRadioButton.Checked = True Then
Do Until foundBoolean Or indexInteger > 55
If .stateText.Text.ToUpper.Trim = USstate(indexInteger).stateNameString.ToUpper.Trim Then
AbText.Text = USstate(indexInteger).abbrString
foundBoolean = True
Else
indexInteger += 1
End If
Loop
If Not foundBoolean Then
MessageBox.Show("the state could not be found", "No match", MessageBoxButtons.OK, MessageBoxIcon.Information)
AbText.SelectAll()
AbText.Focus()
End If
End If
If .NameRadioButton.Checked = True Then
Do Until foundBoolean Or indexInteger > 55
If .AbText.Text.ToUpper.Trim = USstate(indexInteger).abbrString.ToUpper.Trim Then
Me.stateText.Text = USstate(indexInteger).stateNameString
foundBoolean = True
Else
indexInteger += 1
End If
Loop
If Not foundBoolean Then
MessageBox.Show("the state could not be found", "No match", MessageBoxButtons.OK, MessageBoxIcon.Information)
stateText.SelectAll()
stateText.Focus()
End If
End If
End With
End Sub
End Class
Imports System.IO
Public Class Form1
Structure state
Dim stateNameString As String
Dim abbrString As String
End Structure
Dim USstate() As state
Dim stateStreamReader As New StreamReader("structurearray.txt")
Private Sub selectedRadioButton_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NameRadioButton.CheckedChanged, AbbreviationRadioButton.CheckedChanged
Dim selectedRadiobutton As RadioButton
selectedRadiobutton = CType(sender, RadioButton)
If AbbreviationRadioButton.Checked Then
AbbreviationRadioButton = selectedRadiobutton
stateText.Clear()
stateText.ReadOnly = True
AbText.ReadOnly = False
AbText.Focus()
Else
NameRadioButton = selectedRadiobutton
AbText.Clear()
AbText.ReadOnly = True
stateText.Focus()
stateText.ReadOnly = False
End If
End Sub
Private Sub ClearButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearButton.Click
AbText.Clear()
stateText.Clear()
stateText.ReadOnly = False
AbText.ReadOnly = False
AbText.Focus()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub LookUpButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LookUpButton.Click
Dim indexInteger As Integer
Dim foundBoolean As Boolean
With Me
If .AbbreviationRadioButton.Checked Then
Do Until foundBoolean Or indexInteger > 130
If .stateText.Text.Trim = USstate(indexInteger).stateNameString.ToUpper.Trim Then
AbText.Text = stateStreamReader.ReadLine
foundBoolean = True
Else
indexInteger += 1
End If
Loop
If Not foundBoolean Then
MessageBox.Show("the state could not be found", "No match", MessageBoxButtons.OK, MessageBoxIcon.Information)
AbText.SelectAll()
AbText.Focus()
End If
End If
If .NameRadioButton.Checked Then
Do Until foundBoolean Or indexInteger > 55
If .AbText.Text.ToUpper.Trim = USstate(indexInteger).abbrString.ToUpper.Trim Then
Me.stateText.Text = USstate(indexInteger).stateNameString
foundBoolean = True
Else
indexInteger += 1
End If
Loop
If Not foundBoolean Then
MessageBox.Show("the state could not be found", "No match", MessageBoxButtons.OK, MessageBoxIcon.Information)
stateText.SelectAll()
stateText.Focus()
End If
End If
End With
End Sub
End Class
Edited with the full code
Last edited by rollntider; Apr 4th, 2007 at 03:54 PM.
I think my issue is that it is reading the text file , but not loading the array with the info from the text file. let me see if I can stumble onto that
I figured out what I am trying to accomplish. I just cant figure out how to get it to occur.
I am trying to get the contents of the text file into an array.
The first line is the state abbreviation
the second line is the state full name
each odd line is the abbreviation and each even line is the full name.
it would reverse if i select name. it would display the abbreviation if i spell the state
in the above code it is loading the file with my streamreader but i can't figure out how to get it into the array.