Advertisement
C_Volume2 String Manipulation #71583

Trim non alphanumeric characters FAST

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.

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
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]"
Original Comments (3)
Recovered from Wayback Machine