Also consider knowing the Asc of each character.
See Character Sets.....
The Asc(yourvariable) for linefield is 10
The Asc(yourvariable) for carriage return is 13
This routinne ensures at least 1 character is entered
and that something is entered and the checks for linefeeds
or carriage returns which as is quite useless....needs expansion via character set ranges.
'--------------------------
ordernumberraw = TextBox2.Value
ordernumber = Trim(ordernumberraw)
lengthordernumber = Len(ordernumber)
If lengthordernumber < 1 Then
MsgBox "Please enter a valid Order #", vbOKOnly, "Incorrect input"
TextBox2.Value = Empty
GoTo endsubmit
End If
For x = 1 To lengthordernumber
d = Mid(ordernumber, x, 1)
b = Asc(d)
If b = 10 Or b = 13 Then
MsgBox "Please enter a valid Order #", vbOKOnly, "Incorrect input"
TextBox2.Value = Empty
TextBox2.SetFocus
GoTo endsubmit
End If
Next x