str = "1,2,3,4"
arr = split(str,",")
msgbox ubound(arr) '3

解决方案 »

  1.   

    Split
    Returns a zero-based, one-dimensional array containing a specified number of substrings.Syntax
    Split(expression[, delimiter[, count[, compare]]])The Split syntax has these parts:Part Description 
    expression Required. String expression containing substrings and delimiters. If expression is a zero-length string, Split returns an empty array, that is, an array with no elements and no data. 
    delimiter Optional. String character used to identify substring limits. If omitted, the space character (" ") is assumed to be the delimiter. If delimiter is a zero-length string, a single-element array containing the entire expression string is returned. 
    count Optional. Number of substrings to be returned; -1 indicates that all substrings are returned. 
    compare Optional. Numeric value indicating the kind of comparison to use when evaluating substrings. See Settings section for values. 
    Settings
    The compare argument can have the following values:Constant Value Description 
    vbBinaryCompare 0 Perform a binary comparison. 
    vbTextCompare 1 Perform a textual comparison. 
    vbDatabaseCompare 2 Perform a comparison based on information contained in the database where the comparison is to be performed. 
      

  2.   

    Split函数
          描述返回一个下标从零开始的一维数组,它包含指定数目的子字符串。语法Split(expression[, delimiter[, count[, compare]]])Split函数语法有如下几部分:部分 描述 
    expression 必需的。包含子字符串和分隔符的字符串表达式 。如果expression是一个长度为零的字符串(""),Split则返回一个空数组,即没有元素和数据的数组。 
    delimiter 可选的。用于标识子字符串边界的字符串字符。如果忽略,则使用空格字符(" ")作为分隔符。如果delimiter是一个长度为零的字符串,则返回的数组仅包含一个元素,即完整的 expression字符串。 
    count 可选的。要返回的子字符串数,–1表示返回所有的子字符串。 
    compare 可选的。数字值,表示判别子字符串时使用的比较方式。关于其值,请参阅“设置值”部分。 
    设置值compare参数的设置值如下:常数 值 描述 
    vbUseCompareOption –1 用Option Compare语句中的设置值执行比较。 
    vbBinaryCompare 0 执行二进制比较。 
    vbTextCompare 1 执行文字比较。 
    vbDatabaseCompare 2 仅用于Microsoft Access。基于您的数据库的信息执行比较。