The problem logic displays the Root Namespace data in each field; since it appeared to work, I did not change it.
First question: is ‘StateName’ unecessary redunance in USSTLoad(0, 0).StateName?
Second question: is it causing the namespace display? I can see no problem in the For/Next logic. TIA JP
Errant code that displays Root Namespace in each field!Code:Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load ' Add six elements to the structered arrays. USSTLoad(0, 0).StateName = "Alabama" USSTLoad(0, 1).StdAbrv = "Ala." USSTLoad(0, 2).PostalAbrv = "AL" USSTLoad(0, 3).CapitalCity = "Montgomery" USSTLoad(1, 0).StateName = "Alaska" USSTLoad(1, 1).StdAbrv = "Alaaska" USSTLoad(1, 2).PostalAbrv = "Ak" USSTLoad(1, 3).CapitalCity = "Juneau" USSTLoad(2, 0).StateName = "Arizona" USSTLoad(2, 1).StdAbrv = "Ariz." USSTLoad(2, 2).PostalAbrv = "AL" USSTLoad(2, 3).CapitalCity = "Phoenix" USSTLoad(3, 0).StateName = "Arkansas" USSTLoad(3, 1).StdAbrv = "Ark." USSTLoad(3, 2).PostalAbrv = "AR" USSTLoad(3, 3).CapitalCity = "Little Rock" USSTLoad(4, 0).StateName = "California" USSTLoad(4, 1).StdAbrv = "Calf." USSTLoad(4, 2).PostalAbrv = "CA" USSTLoad(4, 3).CapitalCity = "Sacramento" USSTLoad(5, 0).StateName = "Colorado" USSTLoad(5, 1).StdAbrv = "Colo." USSTLoad(5, 2).PostalAbrv = "CO" USSTLoad(5, 3).CapitalCity = "Denver" MaxIndexInterger = 5 ‘ Good Data Displayed MessageBox.Show("Last Entry: " & Environment.NewLine & USSTLoad(MaxIndexInterger, 0).StateName & Environment.NewLine & USSTLoad(MaxIndexInterger, 1).StdAbrv & Environment.NewLine & USSTLoad(MaxIndexInterger, 2).PostalAbrv & Environment.NewLine & USSTLoad(MaxIndexInterger, 3).CapitalCity & Environment.NewLine, "Input Check!", MessageBoxButtons.OK, MessageBoxIcon.Question) End Sub
Code:Private Sub SearchByPostal() For RowIndex As Integer = 0 To MaxIndexInterger ' Error at 'If' statement not working, going to MaxIndexInteger then invokes DisplayFindings() ' at RowIndex = MaxIndexInteger + 1, USSTLoad(RowIndex, 2) Displays Root Namespace! Yet if I ' key in the first structure data point, it knows to stop and display. If PostalAbrvTextBox.Text = USSTLoad(RowIndex, 2).ToString Then DisplayIndex = RowIndex DisplayFindings() Exit For Else MessageBox.Show("RowIndex = " & RowIndex, "Missing input!", MessageBoxButtons.OK, MessageBoxIcon.Question) End If Next RowIndex End Sub Private Sub DisplayFindings() StateNameTextBox.Text = USSTLoad(DisplayIndex, 0).ToString StdAbrvTextBox.Text = USSTLoad(DisplayIndex, 1).ToString PostalAbrvTextBox.Text = USSTLoad(DisplayIndex, 2).ToString StateCapitalTextBox.Text = USSTLoad(DisplayIndex, 3).ToString End Sub




Reply With Quote
