Thursday, March 22, 2012

Structure/Array Question - Easy

I have a Structure and need to create array of Structures for example... How do I accomplish this?

Structure MyStruct

Dim Input1 As String

Dim Input2 As String

End Structure

dim t() as MyStruct

try this

Dim myarray(10)As MyStruct

(if you want the length of the array to be 10)


This is your Structure:

Structure myStruct
Dim Input1 As String
Dim Input2 As String
End Structure

if you want to have an array of your structure with a fix length... then you can do it as..

Dim t(10) As myStruct

if you want to have an array of your structure with dynamic length... i mean if you are not sure what is the length then... you can do it as...

Dim t1() As myStruct
Dim iRow As Integer = 0
While (True) '...an endless loop... just to show example...
ReDim Preserve t1(iRow)
t1(iRow) = New myStruct
t1(iRow).Input1 = ""
t1(iRow).Input2 = ""
iRow += 1
End While

hope it helps./.

0 comments:

Post a Comment