Hi. There is no real sample of validation, just an approach.
Write it out in english
break it down into the smallest parts you can
code each part.
as an example:
I want this textbox to contain at least 6 characters
the content of this textbox, excluding any white space, must exceed 5 characters.
read the content of the textbox
remove whitespace
check the length
if it is greater than 5 carry on
otherwise keep the focus at this texbox and issue an error messagebox.
- Dim stInput As String
-
-
stInput = Trim(TextBox1.Text)
-
If Len(stInput) < 6 Then
-
MsgBox "Input must be 6 characters or more"
-
TextBox1.SetFocus
-
End If