Ho Scott,
maybe this bit of code can help you,
put a button on a form and copy paste the first bit of this code in it's
click event and the next bit behind your form's end class:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles _ Button1.Click
Dim MyInfoArr(2) As Myinfo
For i As Integer = 0 To 2
MyInfoArr(i) = New Myinfo
Select Case i
Case 0
MyInfoArr(i).MyName = "Peter"
MyInfoArr(i).MyCountry = "Belgium"
Case 1
MyInfoArr(i).MyName = "Piedro"
MyInfoArr(i).MyCountry = "Jhonnytown"
Case 2
MyInfoArr(i).MyName = "Mr. Whiskers"
MyInfoArr(i).MyCountry = "Whiskycity"
End Select
Next
For i As Integer = 0 To 2
MsgBox(MyInfoArr(i).ToString)
Next
End Sub
Public Class Myinfo
Private strMyName As String
Private strMyCountry As String
Public Property MyName() As String
Get
Return strMyName
End Get
Set(ByVal Value As String)
strMyName = Value
End Set
End Property
Public Property MyCountry() As String
Get
Return strMyCountry
End Get
Set(ByVal Value As String)
strMyCountry = Value
End Set
End Property
Public Overrides Function ToString() As String
Return "Hi my name is: " & strMyName & " and I live in: " &
strMyCountry & "."
End Function
End Class
Hth Greetz Peter
--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning.
"Scott McNair" <sc**********@sfmco.takethispartout.com> schreef in bericht
news:Xn********************@207.46.248.16...
Hi,
I'm trying to populate a 2-dimensional array by assigning each item its
own instance of a class, for example:
Dim SubSector(8,10) As New SystemClass
...where SystemClass is a class I've defined elsewhere in my code.
However, it won't let me use "New" in the declaration (it gives the error
"Arrays cannot be declared with 'New'") and if I leave "New" out, then
each section of the array contains the exact same data - it's as though instead
of having its own instance of SystemClass, each section is referring to
the original class.
How would I go about making each instance unique unto itself, rather than
all clones of each other?