In my form, there is a textbox where someone can type a string of numbers separated by commas. I want to test whether the last character of the string is a comma or space and warn him to fix:
It does not blow up, it just does not work!
Alan
![[smurf] [smurf] [smurf]](/data/assets/smilies/smurf.gif)
Code:
Public Function CheckFieldSyntax(N As String) As String
[COLOR=red]'If last character is a comma or space, warn user[/color]
Select Case N
Case InStrRev(N, ",", -1) > 5
MsgBox "Your selection may not end in a comma", vbCritical
Case Right(N, 2) = "," & Chr(32)
MsgBox "Check your selection - the ending looks incomplete", vbCritical
Case InStrRev(N, Chr(32), -1) > 0
MsgBox "The end of your selection is a space, please check", vbInformation
Case Else
Debug.Print N & " ~~~ " & Right(N, 1)
End Select
End Function
Alan
![[smurf] [smurf] [smurf]](/data/assets/smilies/smurf.gif)