Sub Main()
Dim letters As String = Console.ReadLine()
If CheckLetters(letters) = False Then
Console.WriteLine("Letters only please.")
Else
Console.WriteLine("You've entered letters only. Hooray.")
End If
Console.ReadLine()
End Sub
Public Function CheckLetters(ByVal letters As String) As Boolean
Dim alphabet As Char() = "abcdefghijklmnopqrstuvwxyz"
For Each c In letters
If alphabet.Contains(c) = False Then
Return False
End If
Next
Return True
End Function
3
u/snang Moderator Nov 02 '20 edited Nov 02 '20
So the first one is easy. You just check the Length of the Text property for the phone number control.
The second, without using RegEx, you're gonna have to loop through the string checking each character and making sure it's a letter, number, or space.
You can accomplish this using a For Next loop and the Substring function on the Text property for the postal code control.
Also, to clarify, if you're not supposed to use stuff like For Next you can just check each character individually using the same Substring logic.
MSDN: For Next Statement, Substring