【SolidWorks宏】VBA 获取数组的长度

REM "获取数组长度"
Public Function ArrayLength(ByVal ary) As Integer
    ArrayLength = UBound(ary) - LBound(ary) + 1
End Function

REM "调用示例"
Sub SplitSample()
    '声明
    Dim temp() As String
    Dim EgStr As String

    '执行过程
    EgStr = "str1   str2    str3"
    temp = Split(EgStr, " ")
    MsgBox(ArrayLength(temp))
End Sub

你可能感兴趣的:(SolidWorks宏)