Object Variable Not Set - Class Module inside Class Module

ShelleyBelly

New Member
Joined
Mar 2, 2011
Messages
44
I'm trying to assign a Class Module known as Port to part of another Class Module , here's the code so far:

The port class module is as follows
Code:
Private pName As String


' Properties
Public Property Let Name(Value As String)
    pName = Value
End Property
Public Property Get Name() As String
    Name = pName
End Property

The "route" class module has the following in it
Code:
Private pDepPort As Port

'Properties
Public Property Let DepPort(Value As Port)
    pDepPort = Value
End Property
Public Property Get DepPort() As Port
    DepPort = pDepPort
End Property

when i run a basic test is get Runtime Error 91 - Object Variable not set.

Code:
Sub checkthis()    
    Dim Rte As Route:   Set Rte = New Route
    Dim Prt As Port:    Set Prt = New Port
    
    Prt.Name = "bonjour"
   
    Rte.DepPort = Prt
    
End Sub
I'm sure it's an easy fix, but i'm on the limit of my knowldege, any help would be appreactied.

Thanks in advance,

Tom
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Your Property Let is missing a Set statement. It should be:

Rich (BB code):
Public Property Let DepPort(Value As Port)
    Set pDepPort = Value
End Property

since you are assigning an object variable. For good order, I'd add a Property Set statement too, but that's optional.
 
Upvote 0

Forum statistics

Threads
1,223,879
Messages
6,175,147
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top