DigitsORLettersOnly

Check if the string has special characters or not, only Letters or digits (DigitsORLetters)
Returns TRUE if string has only letters or digits (no special chars)
FALSE if it has at least one special character (that is not letter nor digit), see examples.
currently works for English language only

Function DigitsORLettersOnly(TheString)
 ' Check if the string has only Letters or digits (DigitsORLetters)
 Rett      = 1
 For i = 1 To Len(TheString)
  Chr1     = Asc(Mid(TheString, i, 1))
  If (Chr1 >= 48 And Chr1 <= 57) Or _
   (Chr1 >= 65 And Chr1 <= 90) Or _
   (Chr1 >= 97 And Chr1 <= 122) _
   Then
   ' We may continue checking
  Else
   Rett    = 0
   Exit For
  End If
Next i
DigitsORLettersOnly = Rett
End Function

TheString

? DigitsORLettersOnly(&#34;days3&#34;)<br/>1<br/>? DigitsORLettersOnly(&#34;days=3&#34;)<br/>0

Views 732 Downloads 319

'String', 'check', 'test', 'special character', 'ascii', 'code', 'mid'

ANmarAmdeen
333
Texts + Strings Classic ASP
Revisions

v1.0