Stripping out punctuation marks
Is there an easy way to edit a string so that only alphabetical characters
and numbers are allowed? Thanks for your help.
Re: Stripping out punctuation marks
Try this function:
Public Function Removes(ByVal mystring As String) As String
Dim newstring As String
For Each character As Char In mystring
If Not Char.IsPunctuation(character) Then newstring &= character
This basically loops through the string and tests whether each character is
punctuation. If it is not, it appends it to a new string. You can use the
same technique for the other Is... methods of the Char type. You can also
use the Replace method to replace all instances of a specific character with
a zero-length String as in the following:
The lower-case c in the code tells VB.NET to interpret the String as a Char.
Try whichever one of these works best for you, if you need more help feel
free to ask. Good Luck!
"dew" <firstname.lastname@example.org> wrote in message
> Is there an easy way to edit a string so that only alphabetical characters
> and numbers are allowed? Thanks for your help.
|All times are GMT. The time now is 03:40 AM.|
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.