by Luis Cantero (14 Submissions)
Category: String Manipulation
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating:
(2 Votes)
It will erase any non-alphanumeric characters from a string rapidly. Usefull if you want to check strings for non-valid characters.
Strings such as email or web addresses, you can even make so that only numbers can be entered in, for example, a text box.
Inputs
Any string
Code Returns
The filtered string
API Declarations
Function TrimVoid(strWhat)
'*************************
'Usage: x = TrimVoid(String)
'*************************
'Example: Chunk = TrimVoid(Chunk)
'Filters all non-alphanumeric characters from string "Chunk".
'*************************
For i = 1 To Len(strWhat)
If Mid(strWhat, i, 1) Like "[a-zA-Z0-9]" Then strNew = strNew & Mid(strWhat, i, 1)
Next
TrimVoid = strNew
End Function
'NOTES - replace the above code with the lines below to get the wanted results.
'For trimming email addresses use this:
'Like "[a-zA-Z0-9._-]"
'For trimming web addresses use this:
'Like "[a-zA-Z0-9._/-]"
'To accept only numbers in a text box use this in the text box's Change Sub:
'Like "[0-9]"