我有以下代码:
Public Function model(s As String) As String()
s = Replace(Replace(s, "-", ","), " ", "")
model = Split(s, ",")
End Function
基本上应该使用s
字符串,例如:
s = "031, 603-604, 803-804, 617, 817, 619, 819, 621, 821, 627, 827, 629, 829, 831, 645-646, 845-846, 647-648, 847-848, 649-650, 849-850, 667-668, 867-868, 671-672, 871-872, 677-678, 675-676, 875-876, 679-680"
并根据它创建一系列代码(模型)。我想以这种方式称呼它:
Sub irrelevant()
Dim s as String
s = <similar string from the above, but directly input from a worksheet cell>
tmpArr = model(s)
Dim iCtr As Long
For iCtr = 0 To UBound(tmpArr)
Debug.Print tmpArr(iCtr)
Next
End sub
这会在tmpArr = model(s)
行上引发错误:
Compile Error:
Expected array