devxlogo

PhoneNumberFromString – Convert a phone string into a number

PhoneNumberFromString – Convert a phone string into a number

' convert a telephone string into a phone numberFunction PhoneNumberFromString(ByVal PhoneString As String) As String    Dim i As Integer    Dim acode As Integer        Const PhoneDigits = "22233344455566677778889999"        ' prepare result in uppercase    PhoneNumberFromString = UCase$(PhoneString)        For i = 1 To Len(PhoneNumberFromString)        acode = Asc(Mid$(PhoneNumberFromString, i, 1))        Select Case acode            Case 48 To 57                ' nothing to do            Case 65 To 90                ' replace with corresponding char in PhoneChars                Mid$(PhoneNumberFromString, i, 1) = Mid$(PhoneDigits, _                    acode - 64, 1)            Case Else                ' raise an error if anything else                Err.Raise 5, , "Invalid character"        End Select    Next    End Function

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist