Dim pages(,) As String? 
Author Message
 Dim pages(,) As String?

This is an extremely easy question but haven't done VB in quite some time.
I have a method that returns a two-dimensional array of strings.  How can i
populate a variable in VB with that 2-D Array?  I tried the followin gbut
not sure of the syntax and the .net documentation doesnt have a VB example
it seems.

Dim pages(,) As String
pages = MyObject.MyMethod()

thanks so much!



Tue, 11 Nov 2003 03:26:03 GMT  
 Dim pages(,) As String?
Hi Christopher,

try something liek this:

   Sub Main()
      Dim s(,) As String
      s = MyMethod()
      Dim i, j As Int32
      For i = 0 To s.GetUpperBound(0)
         For j = 0 To s.GetUpperBound(1)
            Console.WriteLine(s(i, j))
         Next
      Next
   End Sub

   Public Function MyMethod() As String(,)
      Dim MyS(2, 2) As String
      Dim i, j As Int32
      For i = 0 To 2
         For j = 0 To 2
            MyS(i, j) = "Item : " & CStr(i) & ", " & CStr(j)
         Next
      Next
      Return MyS
   End Function


Quote:
> This is an extremely easy question but haven't done VB in quite some time.
> I have a method that returns a two-dimensional array of strings.  How can
i
> populate a variable in VB with that 2-D Array?  I tried the followin gbut
> not sure of the syntax and the .net documentation doesnt have a VB example
> it seems.

> Dim pages(,) As String
> pages = MyObject.MyMethod()

> thanks so much!



Tue, 11 Nov 2003 04:40:26 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Newbie Question: Dim A() as String /Dim A as String()

2. dim string to dim form

3. Dim for strings ? (qbasic)

4. Odd Behavior re: dim as string and then input

5. Efficient use of strings (Dim, Redim, and all that)

6. Dim xxxx AS String * 30

7. Dim a Variable from a string???Possible??

8. Dim a string to a fixed size during runtime

9. Dim a Variable from a string???Possible??

10. Dim a Variable from a string???Possible??

11. Dim obj As New Class crt Dim Obj As Class = New Class

12. dynamically dim a variable ie dim "variable"&n

 

 
Powered by phpBB® Forum Software