'兼容VB，返回 是数组的个数，一维数组下标从零开始，它包含指定数目的子字符串。
'vbSplit( SourceStr as String,delimeter as String, StrArray() as String) as Long
Function vbSplit(SourceStr as String, delimeter as String, StrArray() as String) as Long
   Dim as Integer f1,f2,u,umax,ld
   If SourceStr = "" Then
      Function = -1
      Exit Function
   End If
   ld = Len(delimeter)
   f1 = 1 - ld
   u = -1
   umax = 100  '加速数组操作
   ReDim StrArray(umax)
   Do
      f2 = InStr(f1 + ld, SourceStr, delimeter)
      u += 1
      If u > umax Then
         umax += 100
         ReDim Preserve StrArray(umax)
      End If
      If f2 = 0 Then '没有分割符合了
         StrArray(u) = Mid(SourceStr, f1 + ld)
         Exit Do
      End If
      StrArray(u) = Mid(SourceStr, f1 + ld, f2 - f1 - ld)
      f1 = f2
   Loop
   ReDim Preserve StrArray(u)
   
   Function = u + 1
End Function
