function to remove all except digits

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a string function or other that will remove all characters except
for digits?
trying to make it easy for people to enter a ccn.
 
WebBuilder451 said:
Is there a string function or other that will remove all characters except
for digits?
trying to make it easy for people to enter a ccn.

\\\
Imports System.Text.RegularExpressions
..
..
..
Dim s As String = "&A$§23zb4-u9%%8Z"
MsgBox(Regex.Replace(s, "[^0-9]", ""))
///
 
Might try somethign like this...

Private Function numericstring(ByVal strNumeric As String) As String

Dim strChar As String

Dim strReturn As String = ""

For x As Integer = 0 To strNumeric.Length - 1

strChar = strNumeric.Substring(x, 1)

If Char.IsNumber(strChar) Then

strReturn = strReturn & strChar

End If

Next

numericstring = strReturn

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top