PDA

View Full Version : What's the difference between the dims of Array ?



idnoidno
01-07-2019, 10:53 PM
Type 1

Sub Break_String()
Dim WrdString As String
Dim text_string As String
text_string = "Welcome to Excel Trick"
WrdString = Split(text_string)(2)
MsgBox "The third part is : " & WrdString
End Sub

Type 2

Sub Break_String()
Dim WrdArray() As String
Dim text_string As String
text_string = "Welcome to Excel Trick"
WrdArray() = Split(text_string)
For i = LBound(WrdArray) To UBound(WrdArray)
strg = strg & vbNewLine & "Part No. " & i & " - " & WrdArray(i)
Next i
MsgBox strg
End Sub


What is the difference between the two types of use, with or without parentheses?

Dave
01-08-2019, 12:17 AM
The 1st one gives U the location in the Split array ie. posn 3 in your eg. re. option base 0 for Split (syntax looks wrong??). The 2nd one I believe creates a paraarray (not sure?) and contains the whole string parsed by the Split which is useful if the Split criteria is known eg. a comma. By the way U need to Split a text string by some other text string. Check the Split syntax. HTH. Dave