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