Reputation: 415
I have this,
Public Class posData
Public Property strLabel As String
Public Property strX As String
Public Property strY As String
Public Property blnAvail As Boolean
Public Sub New(ByVal strLabelID As String, ByVal X As Integer, ByVal Y As Integer)
Me.strLabel = strLabelID
' Format = "<PinX F='53mm'></PinX>", "<PinY F='204mm'></PinY>"
Me.strX = "<PinX F='" & X.ToString & "mm'></PinX>"
Me.strY = "<PinY F='" & Y.ToString & "mm'></PinY>"
Me.blnAvail = True
End Sub
End Class
Im utilzing this within another sub to build a list called PosList..
Public Sub SetUpCoords(ByRef PosList As HashSet(Of posData))
Dim a1 As New posData("a1", X_coords(0), Y_coords(0))
Dim a2 As New posData("a2", X_coords(1), Y_coords(0))
Dim a3 As New posData("a3", X_coords(2), Y_coords(0))
and so on and so on, however i want to call this method and populate the list in my button click sub so i have added this in my button click event.
Dim MyPosList As New HashSet(Of posData)
SetUpCoords(MyPosList)
then i want to loop through all the objects within my list so i have a for each position in posList, inside this is where the problem occurs, i want to be able to write something like this, a1.blnavail, this is not happening however, i know i can use position.blnavail but i need to hardcode the position for my logic to work correctly, what am i doing wrong?
thanks :)
Upvotes: 0
Views: 516
Reputation: 6821
Couldn't you use another data structure, like a Dictionary, that uses a key? You could then key each item with a1 etc. and access the items in a for loop using the key.
Upvotes: 1