VBA Len函數
Len :
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