vendredi 17 avril 2015

VB6 comparing only numeric characters in srings

I need to compare phone numbers from a CSV file to phone numbers in a database in VB6 without using the .Net Library. One may have a number as 555-555-5555 and the other may have the same number as (555) 555-5555 which obviously kicks back as different when strings are compared. I know I can use for loops and a buffer to pull out only numeric characters like:



Public Function PhoneNumberNumeric(PhoneNumberCSV As String) As String
Dim CharNdx As Integer
Dim buffer As String
For CharNdx = 1 To Len(PhoneNumberCSV) Step 1
If IsNumeric(Mid(PhoneNumberCSV, CharNdx, 1)) Then
buffer = buffer + Mid(PhoneNumberCSV, CharNdx, 1)
End If
Next
PhoneNumberNumeric = buffer
End Function


but this is expensive. Is there a less expensive way to do this?


Aucun commentaire:

Enregistrer un commentaire