This is a program where you can enter 2 first letters of a state in the masked textbox, click the search button, and see the full name of the state displayed inside a regular textbox.
I am having a little problem at the end getting txtOutput.Text to produce the name of the state selected. Here is what i have:
Code:Private Sub btnSearch_Click(sender As System.Object, e As System.EventArgs) Handles btnSearch.Click Dim first, last, middle As Integer Dim flag As Boolean = False first = 0 last = lstStates.Items.Count - 1 Dim letters As String = mtbFirstTwoLetters.Text.ToUpper While first <= last middle = CInt((first + last) / 2) Dim state As String = CStr(lstStates.Items.Item(middle)).ToUpper If state.StartsWith(letters) Then flag = True Exit While Else Dim st As String = state.Substring(0, 2) If letters > st Then first = middle + 1 Else last = middle - 1 End If End If End While If flag Then txtOutput.Text = Else txtOutput.Text = "The State Is Not Found" End If End Sub End Class




Reply With Quote