This seems strange, but maybe there's some basic concept I'm missing.
When I assign one class member to another, any methods that are applied
to one are applied to both variables.I can't get the code below to work
(display sum, product and quotient) without re-initializing z1 each
time. What's the problem here?
Dim z0 As Complex = New Complex(CDbl(Me.TextBox1.Text),
CDbl(Me.TextBox2.Text))
Dim z1 As Complex = New Complex(CDbl(Me.TextBox1.Text),
CDbl(Me.TextBox2.Text))
Dim z2 As Complex = New Complex(CDbl(Me.TextBox3.Text),
CDbl(Me.TextBox4.Text))
z1.Add(z2) ' Add z1 and z2
z1 = z0 ' Reassign z0 to z1
z1.Multiply(z2) ' Multiplies z0!
z1 = z0
z1.Divide(z2)
Public Class Complex
Private re As Double
Private im As Double
Public Sub New(ByVal x As Double, ByVal y As Double)
re = x
im = y
End Sub