3 Replies - 760 Views - Last Post: 18 June 2011 - 07:15 PM Rate Topic: -----

#1 ssharma286  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 93
  • Joined: 04-December 10

Using arrays with structures

Posted 18 June 2011 - 05:55 PM

Okay so I have created a structure as below. I want the structure to be an array...so I can use a call like picks(1).a or picks.a(1) = blah blah. I don't understand how to use an array of a structure..
 Public Structure apicks
        Dim a As String
        Dim b As String
    End Structure 

Is This A Good Question/Topic? 0
  • +

Replies To: Using arrays with structures

#2 _HAWK_  Icon User is online

  • Master(Of Foo)
  • member icon

Reputation: 1055
  • View blog
  • Posts: 4,087
  • Joined: 02-July 08

Re: Using arrays with structures

Posted 18 June 2011 - 06:03 PM

How about a List(Of T)?

Dim picks As New List(Of apicks)

picks.Add(New apicks With {.a = "foo", .b = "blah"})

picks(0).a = "foo"

Was This Post Helpful? 0
  • +
  • -

#3 ssharma286  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 93
  • Joined: 04-December 10

Re: Using arrays with structures

Posted 18 June 2011 - 06:10 PM

It doesn't seem to be working. I really was hoping to use a struct based array since I already know how to work with one. I just need something so I can go picks.a(1) = "omg!" or some other variation of that. Using the list code you provided it gave me a whole bunch of syntax errors
Was This Post Helpful? 0
  • +
  • -

#4 _HAWK_  Icon User is online

  • Master(Of Foo)
  • member icon

Reputation: 1055
  • View blog
  • Posts: 4,087
  • Joined: 02-July 08

Re: Using arrays with structures

Posted 18 June 2011 - 07:15 PM

Oh, you need an array inside the structure. Well...

Public Structure apicks
       Dim a As New List(Of String)
End Structure 

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1