Hi guys,
I have been stuck on a simple code for hours can anyone help? The question is:
"Suppose an array of 16 names is in ascending order. Write a procedure to search for a name input by the user. If the first letter of the name is found in N through Z, then the search should begin with the 16th element and proceed backward. "
My professor wants me to change the code I have so that it handles when the name is not in the list and will then display "name not found".
Also, change it so that it will display "name found" when the name IS on the list.
This is what I have so far...
Private Sub btnName_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnName.Click
Dim nom() As String = {"AL", "BOB", "CARL", "DAVID", "DON", "ERIC", "FRED", "GREG", "HERB", "IRA", "JACK", "MARTHA", "NANCY", "RUBEN", "STEVE", "TOM"}
Dim index As Integer
Dim inName As String
Dim found As String
inName = mtxtName.Text
found = "false"
If inName.Substring(0, 1) >= "n" Then
txtDisplay.Text = "Name Found"
nom(index) = inName
found = "true"
End If
If index = index - 1 Then
txtDisplay.Text = "Name Not Found"
nom(index) = inName
found = "true"
Else
index = index + 1
txtDisplay.Text = "Incorrect entry"
End If
End Sub