I am trying to split a string into an array in VB6.
The string is stored in a database and looks like this:
"By Value : "
Sometimes it may include something more at the end after the colon, this is why I want to split it as I am comparing it in an if statement, as shown below.
Overall my code goes like this:
Dim deliveryType(2) As String
deliveryType = Split(vaGoodsInLine.FieldValue("Comment"), ":")
If deliveryType(0) = "By Value " Then
'Do Something
End IF
I am getting the following error
I also tried defining the array as a variant with no size like this:
Public deliveryType() As Variant


deliveryTypeas Variant, then you should have not done that. You should have removed the fixed size.Dim deliveryType(2) As Stringshould just beDim deliveryType() As String. Then, the original should be fine. For the second, you could tryDim deliveryType As Variant, without()s, as Variant can already accept both arrays and non arrays.