I have an assignment that asks me to do the following things:
1. Create a textbox to get the student's first and last name (ie: John Ark)
2. If the student's "first letter of his last name" (which is "A" in John Ark) ranged from A to I, then puts him in Group 1.
From J to S: Group 2
From T to Z: Group 3
3. Display the answer (ie: "John Ark is in Group 1")
Here's my code (I just want to test the first Group (A-I)):
Dim strname As String = Me.txtenter.Text Dim strPattern1 As String Dim intpos As Integer intpos = strname.IndexOf(" ") Dim strnew As String strnew = strname.Substring(Val(intpos), 2) 'Locate the last name's first letter strPattern1 = "[A-I]" Me.lblanswer.Text = strnew Like strPattern1
I enter "John Ark", the his last name's first letter is "A", which lies exactly in Group 1. Thus, the "Like operator" is supposed to say "True". But the problem is: it keeps saying "False".
Can anybody tell me what is wrong with my code, please?