| Visual Basic Scripting Edition | 語言參考 |
Split 函數返回基于 0 的一維數組,其中包含指定數目的子字符串。 Split(expression[, delimiter[, count[, start]]])
參數expression 必選項。字符串表達式,包含子字符串和分隔符。如果 expression 為零長度字符串,Split 返回空數組,即不包含元素和數據的數組。 delimiter 可選項。用于標識子字符串界限的字符。如果省略,使用空格 ("") 作為分隔符。如果 delimiter 為零長度字符串,則返回包含整個 expression 字符串的單元素數組。 count 可選項。被返回的子字符串數目,-1 指示返回所有子字符串。 Compare 可選項。指示在計算子字符串時使用的比較類型的數值。有關數值,請參閱“設置”部分。 設置compare 參數可以有以下值: | 常數 | 值 | 描述 |
|---|
| vbBinaryCompare | 0 | 執(zhí)行二進制比較。 | | vbTextCompare | 1 | 執(zhí)行文本比較。 |
說明下面的示例利用 Split 函數從字符串中返回數組。函數對分界符進行文本比較,返回所有的子字符串。 Dim MyString, MyArray, Msg
MyString ="VBScriptXisXfun!"
MyArray =Split(MyString, "x", -1, 1)
' MyArray(0) contains "VBScript".
' MyArray(1) contains "is".
' MyArray(2) contains "fun!".
Msg =MyArray(0) & " " & MyArray(1)
Msg =Msg & " " & MyArray(2)
MsgBox Msg
要求版本 2 請參閱Join 函數
返回首頁 |