D
Derek
Hello...Maybe I am not understanding how object arrays are created - but
this problem has bothered me for some time now - Take a quick look at the
code and then my 'problem' below:
#CODE#
Public Class CustomerInfo
Dim _billto() As BillTo
Public Overloads ReadOnly Property Billing() As BillTo()
Get
Return _billto
End Get
End Property
Public Overloads ReadOnly Property Billing(ByVal index As Integer) As
BillTo
Get
Return _billto(index)
End Get
End Property
Public Sub AddBillto(ByVal bill As BillTo)
If _billto Is Nothing Then
ReDim _billto(0)
_billto(0) = bill
Else
ReDim Preserve _billto(UBound(_billto) + 1)
_billto(UBound(_billto)) = bill
End If
End Sub
End Class
Public Class customer
Private _name As String
Public Property Name() As String
Get
Return _name
End Get
Set(ByVal Value As String)
_name = Value
End Set
End Property
Public Sub Clear()
_name = ""
End Sub
End Class
Public Class BillTo
Inherits customer
End Class
#END CODE#
This is over-simplified code of course but I just wanted it to explain this
behavior - In a form I have the following code:
Private _custinfo As New CustomerInfo
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim bleh As New BillTo
bleh.Name = "test string"
_custinfo.AddBillto(bleh)
bleh.Clear()
MsgBox(_custinfo.Billing(0).Name)
End Sub
What I don't understand is why the bleh.Clear event would also be clearing
the _custinfo.Billing(0).Name 's value....Any explanations? Workarounds?
Thanks!
this problem has bothered me for some time now - Take a quick look at the
code and then my 'problem' below:
#CODE#
Public Class CustomerInfo
Dim _billto() As BillTo
Public Overloads ReadOnly Property Billing() As BillTo()
Get
Return _billto
End Get
End Property
Public Overloads ReadOnly Property Billing(ByVal index As Integer) As
BillTo
Get
Return _billto(index)
End Get
End Property
Public Sub AddBillto(ByVal bill As BillTo)
If _billto Is Nothing Then
ReDim _billto(0)
_billto(0) = bill
Else
ReDim Preserve _billto(UBound(_billto) + 1)
_billto(UBound(_billto)) = bill
End If
End Sub
End Class
Public Class customer
Private _name As String
Public Property Name() As String
Get
Return _name
End Get
Set(ByVal Value As String)
_name = Value
End Set
End Property
Public Sub Clear()
_name = ""
End Sub
End Class
Public Class BillTo
Inherits customer
End Class
#END CODE#
This is over-simplified code of course but I just wanted it to explain this
behavior - In a form I have the following code:
Private _custinfo As New CustomerInfo
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim bleh As New BillTo
bleh.Name = "test string"
_custinfo.AddBillto(bleh)
bleh.Clear()
MsgBox(_custinfo.Billing(0).Name)
End Sub
What I don't understand is why the bleh.Clear event would also be clearing
the _custinfo.Billing(0).Name 's value....Any explanations? Workarounds?
Thanks!