complex numbers

F

Fcoatis

Getting stuck here.

In class called cNum I have this:

Option Explicit

Private m_rP As Double
Private m_iP As Double

Public Property Get rP() As Variant
rP = m_rP
End Property

Public Property Let rP(ByVal rPart As Variant)
rP = m_rPart
End Property

Public Property Get iP() As Variant
iP = m_iP
End Property

Public Property Let iP(ByVal iPart As Variant)
iP = m_iPart
End Property

In a module I have this:

Sub test()
Dim cNum1 As cNum
cNum1 = Set_cNum(11, 3)
End Sub

Function Set_cNum(rPart As Double, iPart As Double) As cNum
Set_cNum.rP = rPart
Set_cNum.iP = iPart
End Function


But I dont know where´s the flaw.
TIA

Fabio Coatis
 
J

Jim Rech

But I dont know where´s the flaw.

Besides some typos in the class module you never actually instantiated the
class.

Private m_rP As Double
Private m_iP As Double

Public Property Get rP() As Variant
rP = m_rP
End Property

Public Property Let rP(ByVal rPart As Variant)
m_rP = rPart
End Property

Public Property Get iP() As Variant
iP = m_iP
End Property

Public Property Let iP(ByVal iPart As Variant)
m_iP = iPart
End Property

Module:

Sub test()
Dim cNum1 As cNum
Set cNum1 = set_cnum(11, 3)
Debug.Print cNum1.rP
Debug.Print cNum1.iP
End Sub

Function set_cnum(rPart As Double, iPart As Double) As cNum
Dim x As New cNum
x.rP = rPart
x.iP = iPart
Set set_cnum = x
End Function


--
Jim
Getting stuck here.

In class called cNum I have this:

Option Explicit

Private m_rP As Double
Private m_iP As Double

Public Property Get rP() As Variant
rP = m_rP
End Property

Public Property Let rP(ByVal rPart As Variant)
rP = m_rPart
End Property

Public Property Get iP() As Variant
iP = m_iP
End Property

Public Property Let iP(ByVal iPart As Variant)
iP = m_iPart
End Property

In a module I have this:

Sub test()
Dim cNum1 As cNum
cNum1 = Set_cNum(11, 3)
End Sub

Function Set_cNum(rPart As Double, iPart As Double) As cNum
Set_cNum.rP = rPart
Set_cNum.iP = iPart
End Function


But I dont know where´s the flaw.
TIA

Fabio Coatis
 
F

Fcoatis

Besides some typos in the class module you never actually instantiated the
class.

Private m_rP As Double
Private m_iP As Double

Public Property Get rP() As Variant
    rP = m_rP
End Property

Public Property Let rP(ByVal rPart As Variant)
    m_rP = rPart
End Property

Public Property Get iP() As Variant
    iP = m_iP
End Property

Public Property Let iP(ByVal iPart As Variant)
    m_iP = iPart
End Property

Module:

Sub test()
    Dim cNum1 As cNum
    Set cNum1 = set_cnum(11, 3)
    Debug.Print cNum1.rP
    Debug.Print cNum1.iP
End Sub

Function set_cnum(rPart As Double, iPart As Double) As cNum
    Dim x As New cNum
    x.rP = rPart
    x.iP = iPart
    Set set_cnum = x
End Function


ooops

Thanks Jim for the correction.
Regards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top