0
我正在转换的Excel VBA代码下面的JavaScript用在谷歌Google Apps脚本谷歌表工作。不幸的是,我有足够的新的JavaScript想出在JavaScript正确的语法就像是一个飞镖投掷盲镖。 与其花费数小时试图去猜它的工作,我想检查是否有人能帮助我把它转换。我主要是卡在未来与同等的...... 如果(ASC()...结束如果 ...部分功能。VBA相当于在JavaScript在谷歌Apps脚本使用了谷歌表
Public Function cleanPhoneNumber(thisNumber As String) As String
' this function aspires to clean any phone number format
' to standard format (+9999) 999-999-9999 or 999-999-9999
' works with almost all phone number formats stored in text
Dim retNumber As String
For i = 1 To Len(thisNumber)
If Asc(Mid(thisNumber, i, 1)) >= Asc("0") And Asc(Mid(thisNumber, i, 1)) <= Asc("9") Then
retNumber = retNumber + Mid(thisNumber, i, 1)
End If
Next
If Len(retNumber) > 10 Then
' format for country code as well
cleanPhoneNumber = Format(retNumber, "(+#) 000-000-0000")
Else
cleanPhoneNumber = Format(retNumber, "000-000-0000")
End If
End Function