Optional Arguments in Properties of a Class

XonsArgi

New Member
Joined
Apr 18, 2016
Messages
20
I have a class for a cylinder and i want the user to have the option not only to read the volume of the cylinder but to write the volume and preserve the height, radius or proportion by user's choice. I'm with this code for that condition:

Code:
Public Enum PreserveRelationType
    PreserveRadius = 0
    PreserveHeight = 1
    PreserveProportion = 2
End Enum


Public Property Get Volume() As Double
    TotalSurface = AreaOfCircle(Radius) * p_Vector.Module
End Property


Public Property Let Volume(Optional Preserving As PreserveRelationType = 2, Value As Double)
    Select Case Preserving
        Case 0
            p_Vector.Module = 2
        Case 1
        Case 2
    End Select
End Property

But when i try to compile i get the error:

Definitions of property procedures for the same property are inconsistent, or property procedure has an optional parameter, a ParamArray, or an invalid Set final parameter

Anyone knows what should I do?
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
To get things done for a while i'm using the property let with a diferent name, VolumePreserving if any wants to know
 
Upvote 0

Forum statistics

Threads
1,214,965
Messages
6,122,500
Members
449,090
Latest member
RandomExceller01

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