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