-
I guess I should have been more clear. Can someone please explain to me the split function.
Can it seperate a string like "KooKooKaChoo" into 12 different strings,
(or more preferrable) 1 stringarray?
Like say...Oh I don't know...strWheresWaldo(11) as string?????
Thanks!
Lee
-
-
Copy this to a module and try this. It split on each space and sticks into an array.
Code:
Option Explicit
Sub Main()
'PURPOSE:Break up string basing on " " and stick into an array
Dim str_Split() As String
str_Split = Split("Koo Koo Ka Choo", " ")
Dim int_X As Integer
Dim str_Data As String
For int_X = LBound(str_Split) To UBound(str_Split)
str_Data = str_Data & vbCrLf & str_Split(int_X)
Next
MsgBox str_Data
End Sub
If you want 12 different string, copy this instead.
Code:
Option Explicit
Sub Main()
Dim str_Split(11) As String
Dim int_X As Integer
Dim str_Data As String
str_Data = "KooKooKaChoo"
For int_X = 0 To Len(str_Data) - 1
str_Split(int_X) = Mid(str_Data, int_X + 1, 1)
MsgBox str_Split(int_X)
Next
End Sub
-
You are truly ..."The Master!"
Thanks
Lee
-
<?>
Option Explicit
Code:
'you can split on spaces like this as well
Private Sub Command1_Click()
Dim myVar As Variant 'has to be variant
Dim strData As String
strData = "Koo Koo Ka Choo"
myVar = Split(strData, " ")
'for display only
Dim x As Integer, msg As String
For x = LBound(myVar) To UBound(myVar)
msg = msg & myVar(x) & vbCrLf
Next x
MsgBox msg
End Sub