我有以下代码
Sub Test()
Dim path As String
Dim pathSize As Integer
path = "1,45,6,131,13,71,35,141"
pathSize = Split(path, ",").Length
MsgBox (CStr(pathSize))
End Sub
我打算通过将分隔符“,”拆分为包含1,45,6,131,13,71,35和141的数组并测量数组的大小来确定路径的大小。但是,当我运行此代码时,我在行
处收到错误pathSize = Split(path, ",").Length
错误“需要对象”。我在这里做错了什么?
答案 0 :(得分:1)
试试这个
pathSize = Ubound(Split(path, ","))+1