Declaring a dynamic two-dimensional array

I can, quite easily declare an array in a parameter list of a procedure and now, after some guidance(!!) pass an array to the procedure.  However, in a different procedure I wish to pass a two-dimensional array.  I have a Videosoft VSPrinter control.  Here is the code:

Public Sub TableData(Data() As Variant)
   
With VsPrinter1
    .StartTable
    .PenWidth = 15
    .FontBold = True
    .CurrentX = "15mm"
    .CurrentY = "110mm"
    .TextAlign = taLeftTop
    .MarginLeft = 900
    .AddTableArray _ "<40mm|<25mm|<85mm|<50mm|<20mm|<40mm" _ , "Exp./Comm|Quantity|Description|" & _ "Price|Trade Discount|Value", Body
    .TableCell(tcFontBold, 1, 1, _ UBound(Data, 2) + 1, UBound(Data, 1) _ + 1) = False
 '   .TableCell(tcRowHeight, 1, , _ UBound(Body, 2) + 1) = "5mm"
    .TableCell(tcAlign, 0, 1, 0, 6) _
= taCenterTop
    .EndTable
    BottomOfTable = .CurrentY
End With

End Sub


Private objVsView As New clsVsView
Dim SuppDet(0 To 4) As String
Dim DelDet(0 To 4) As String

Private Sub Form_Click()

Dim Body(0 To 5, 0 To 31) As String

With objVsView
    .Fax = "01376 557732"
    .TelNo = "01376 552525"
    .PicturePath = "\\nt-its2 _ \progs\app\purchasi\16bit\copy of _ BRAIN1.bmp"
    .Initialize
    SuppDet(0) = "Andrew Currie"
    SuppDet(1) = "Windsor Castle"
    SuppDet(2) = "London"
    SuppDet(3) = "GLC"
    SuppDet(4) = "UK"
    .SupplierDet SuppDet
    .DeliveryDet
    For i = 0 To 5
        For x = 0 To 31
            Body(i, x) = "Hello! Blah _ Blah Blah!!!"
        Next x
    Next i
    .TableData Body
    .PrintDoc
End With

Set objVsView = Nothing

End Sub
andcuAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

andcuAuthor Commented:
P.S.  TableData is in a Class Module
0
caraf_gCommented:
You haven't told us what your problem is...
0
andcuAuthor Commented:
Oh yeah!!!

Same problem as in my previous ? caraf_g

Error is type mismatch.  Array or user defined-type expected.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

caraf_gCommented:
Ah, of course...

You've declared Body as a 2-dimensional array of Strings and TableData expects and array of Variants.

Either declare Body as an array of variants, or change TableData so it passes in ByVal Body() As Variant
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
caraf_gCommented:
i.e.

Public Sub TableData(ByVal Data() As Variant)
     
0
andcuAuthor Commented:
I get a compile error. Array argument must be byref.
0
caraf_gCommented:
Ok, then the only option open to you is to

Dim Body(0 To 5, 0 To 31) As Variant

in sub Form_Click



0
andcuAuthor Commented:
That worked. Excellent.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.