Split()
函式返回一個陣列,其中包含基於分隔符分割的特定數量的值。
Split(expression[,delimiter[,count[,compare]]])
引數說明
-1
,則返回所有子字串。新增一個模組,並新增以下程式碼 -
Private Sub Constant_demo_Click()
' Splitting based on delimiter comma '$'
Dim a as Variant
Dim b as Variant
a = Split("Red $ Blue $ Yellow","$")
b = ubound(a)
For i = 0 to b
msgbox("The value of array in " & i & " is :" & a(i))
Next
End Sub
當執行上面的函式時,它會產生下面的輸出。
The value of array in 0 is :Red
The value of array in 1 is : Blue
The value of array in 2 is : Yellow