I am taking a shot here because i am frustrated. I am sure this will sound basic to many of you but I am struggling with validation errors on my customer information form. Although I can check whether it is alpabetic or numeric it only checks the first character. If I enter "R3" for example it allows it. I know that I need to run a for next loop to check the whole string but I am not having any luck writing the code for it. Any help would be immensely appreciated. I found some code in this forum but don't know how to apply it to my project for class.
Here is what I found:
my two fields are txtName.Text and txtCity.Text thank you for a little hand holding.Code:Public Function checkAlphaNumeric(strInputText As String) _ As Boolean Dim intCounter As Integer Dim strCompare As String Dim strInput As String checkAlphaNumeric = False For intCounter = 1 To Len(strInputText) strCompare = Mid$(strInputText, intCounter, 1) strInput = Mid$(strInputText, intCounter + 1, Len _ (strInputText)) If strCompare Like ("[A-Z]") Or _ strCompare Like ("[a-z]") Or _ strCompare Like ("#") Then checkAlphaNumeric = True Else checkAlphaNumeric = False Exit Function End If Next intCounter End Function


Reply With Quote




Bookmarks