Remove formatting from a string: “(123) 456-7890” => “1234567890”?

后端 未结 14 726
一整个雨季
一整个雨季 2021-02-05 01:12

I have a string when a telephone number is inputted - there is a mask so it always looks like \"(123) 456-7890\" - I\'d like to take the formatting out before saving it to the D

14条回答
  •  北荒
    北荒 (楼主)
    2021-02-05 01:14

    'you can use module / inside sub main form VB.net
    Public Function ClearFormat(ByVal Strinput As String) As String
        Dim hasil As String
        Dim Hrf As Char
        For i = 0 To Strinput.Length - 1
            Hrf = Strinput.Substring(i, 1)
            If IsNumeric(Hrf) Then
                hasil &= Hrf
            End If
        Next
        Return Strinput
    End Function
    'you can call this function like this
    ' Phone= ClearFormat(Phone)
    

提交回复
热议问题