Len
函式返回給定輸入字串的長度,包括空格。
Len(String)
新增一個模組,並將下面的程式碼放在編輯器中。
Private Sub Constant_demo_Click()
Dim var1 as Variant
Dim var2 as Variant
var1 ="Microsoft VBScript"
msgbox("Length of var1 is : " & Len(var1))
var2 = " Microsoft VBScript "
msgbox ("Length of var2 is : " & Len(var2))
End Sub
執行上面範例程式碼,得到以下結果 -
Length of var1 is : 18
Length of var2 is : 36