G Guest Nov 1, 2005 #1 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.
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.
H Herfried K. Wagner [MVP] Nov 1, 2005 #2 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. Click to expand... \\\ Imports System.Text.RegularExpressions .. .. .. Dim s As String = "&A$§23zb4-u9%%8Z" MsgBox(Regex.Replace(s, "[^0-9]", "")) ///
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. Click to expand... \\\ Imports System.Text.RegularExpressions .. .. .. Dim s As String = "&A$§23zb4-u9%%8Z" MsgBox(Regex.Replace(s, "[^0-9]", "")) ///
J Jim Underwood Nov 1, 2005 #3 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
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