View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Robert Crandal[_2_] Robert Crandal[_2_] is offline
external usenet poster
 
Posts: 158
Default 2D array of strings problem

Thanks, that worked perfectly.

BTW, is it possible to have a 2D array dimensioned
like this:

ReDim (0 to A, 0 to 0) ' Is this possible?

I'm thinking that the second element will usually contain
ONE element, but it will be at index "0".



"joeu2004" wrote in message
...
On Feb 18, 10:18 pm, "Robert Crandal" wrote:
Sub DoStuff (A as Integer, B as Integer)
Dim (A, B) as String ' This creates an error!
End Sub
[....]
Is it possible to create a 2D array whose size depends
on the values of A and B above?

Yes: use ReDim instead Dim. For example:

Sub doit1(a As Long, b As Long)
ReDim s(a, b) As String
MsgBox "a=" & a & " b=" & b & Chr(10) & _
LBound(s, 1) & ":" & UBound(s, 1) & _
" " & LBound(s, 2) & ":" & UBound(s, 2)
End Sub