Split OpenArgs to Multi-Dimension Array (1 Viewer)

modest

Registered User.
Local time
Today, 07:36
Joined
Jan 4, 2005
Messages
1,220
My openargs look something like this:
"Form=Main;MondayOnly=True;X=2500;Y=800"

Code:
[color=blue]Dim[/color] args() [color=blue]As String[/color]

[color=blue]ReDim[/color] args([color=blue]UBound([/color]Split(Me.OpenArgs, ";")[color=blue])[/color],1) [color=green]'resizes the 4 by 2 array[/color]
args = Split(Me.OpenArgs, ";")                [color=green]'correctly puts each section into array[/color]

[color=green]'--------------------------------
'here is where the logic goes bad
'--------------------------------[/color]
[color=blue]For[/color] i = 0 [color=blue]To UBound([/color]args[color=blue])[/color]
    args(i) = Split(args(i), "=")
[color=blue]Next[/color]


I want the end array to be like:
args(0,0) = "Form"
args(0,1) = "Main"
args(1,0) = "MondayOnly"
args(1,1) = "True"
args(2,0) = "X"
args(2,1) = "2500"
args(3,0) = "Y"
args(3,1) = "800"


I know I can do this using left(instr("=")) ... but i was wondering if anyone knew how to make the split() go into a multi-dimensional array.


--- Certainly catching some problems today ---


Thanks, Modest
 
Last edited:

modest

Registered User.
Local time
Today, 07:36
Joined
Jan 4, 2005
Messages
1,220
I really didn't want to use more than one variable (trying to keep it neat) but i used two temp variables to get:

Dim args() As String
Dim tmp() As String
Dim tmp2() As String

tmp = Split(Me.OpenArgs, ";")
ReDim args(UBound(tmp), 1)
For i = 0 To UBound(args, 1)
'ReDim tmp(UBound(Split(args(i), "=")))
tmp2 = Split(tmp(i), "=")
For j = 0 To UBound(tmp2)
args(i, j) = tmp2(j)
Next
Next
 

Users who are viewing this thread

Top Bottom