|
|
Joined: Dec 1999
Posts: 30,867
Master Elite Member
|
Public Function AsCharType_Char(Char As String) As enumCharType
'Purpose
' Used to determine what type a character is.
' All ASCII characters above 127 are considered "Extended" (Extended_CharType).
'Parameters
' Char (String) = The character we're testing.
' If this is longer that 1 character, only the first character is used.
'Return (enumCharType)
' Returns the char type of the specified character.
' Possible return values are:
' "AlphabeticSmall_CharType" Small letter, like: "a" "b" "c" "d" ...
' "AlphabeticCapital_CharType" Capital letter, like: "A" "B" "C" "D" ...
' "Numeric_CharType" 0 1 2 3 4 5 6 7 8 9
' "NonPrintable_CharType" Non displayable characters like: NUL, BELL, TAB, CR, LF, ...
' "Printable_CharType" Printable non-alphanumeric characters like: "?" "(" "~" ...
' "Extended_CharType" Characters with an ASCII code above 127
' If Char is zero-length, function returns zero.
'Dependencies
' enumCharType
'Version History
' 1.0 3/27/2006 3:38am Tested by Russ Tanner on VB 6 Win 2000
'---
'Initiate variables
Dim X As String 'the single character we're testing
'Default return value
AsCharType_Char = 0
'Trap: Char is zero-length, return a zero-length string and exit now
If Len(Char) = 0 Then Exit Function
'Get the single character we're working on
X = Left(Char, 1)
'"Alphabetic Small"
If _
Asc(X) >= 97 And Asc(X) <= 122 _
Then
AsCharType_Char = AlphabeticSmall_CharType
'"Alphabetic Capital"
ElseIf _
Asc(X) >= 65 And Asc(X) <= 90 _
Then
AsCharType_Char = AlphabeticCapital_CharType
'"Numeric"
ElseIf _
Asc(X) >= 48 And Asc(X) <= 57 _
Then
AsCharType_Char = Numeric_CharType
'"Non Printable"
ElseIf _
(Asc(X) >= 0 And Asc(X) <= 31) Or _
Asc(X) = 127 _
Then
AsCharType_Char = NonPrintable_CharType
'"Printable"
ElseIf _
(Asc(X) >= 32 And Asc(X) <= 47) Or _
(Asc(X) >= 58 And Asc(X) <= 64) Or _
(Asc(X) >= 91 And Asc(X) <= 96) Or _
(Asc(X) >= 123 And Asc(X) <= 126) _
Then
AsCharType_Char = Printable_CharType
'"Extended"
ElseIf _
Asc(X) >= 128 _
Then
AsCharType_Char = Extended_CharType
End If
End Function
|
|
|
|
Entire Thread
|
Used to determine what type a character is.
|
Russ
|
08/11/08 10:15 PM
|
|
|
|