Microsoft Access modString
Jump to navigation
Jump to search
getAlNumString
Public Function getAlNumString(strSource As String) As String
Dim strResult As String
Dim intIndex As Integer
Dim strCharacter As String
strResult = ""
For intIndex = 1 To Len(strSource)
strCharacter = Mid(strSource, intIndex, 1)
Select Case Asc(strCharacter)
''A - Z, a - z
Case 65 To 90, 97 To 122
strResult = strResult & strCharacter
'0 - 9
Case 48 To 57
strResult = strResult & strCharacter
Case Else
'nothing
End Select
Next
getAlNumString = strResult
End Function
getAlNumPunctString
Public Function getAlNumPunctString(strSource As String) As String
Dim strResult As String
Dim intIndex As Integer
Dim strCharacter As String
strResult = ""
For intIndex = 1 To Len(strSource)
strCharacter = Mid(strSource, intIndex, 1)
Select Case Asc(strCharacter)
'A - Z, a - z
Case 65 To 90, 97 To 122
strResult = strResult & strCharacter
'0 - 9
Case 48 To 57
strResult = strResult & strCharacter
'<space>, <comma>, <hyphen>, <dot>, <slash>
Case 20, 44 To 47
strResult = strResult & strCharacter
Case Else
'nothing
End Select
Next
getAlNumPunctString = strResult
End Function
getPrintableString
Public Function getPrintableString(strSource As String) As String
Dim strResult As String
Dim intIndex As Integer
Dim strCharacter As String
strResult = ""
For intIndex = 1 To Len(strSource)
strCharacter = Mid(strSource, intIndex, 1)
Select Case Asc(strCharacter)
'ASCII printable characters
Case 20 To 126
strResult = strResult & strCharacter
Case Else
'nothing
End Select
Next
getPrintableString = strResult
End Function
matches
Public Function matches(strString As String, strRegEx As String) As Boolean
Dim blnResult As Boolean
Dim rgx As RegExp
Set rgx = New RegExp
With rgx
.Pattern = strRegEx
blnResult = .Test(strString)
End With
matches = blnResult
End Function