Avatar of Javin007
Javin007
Flag for United States of America asked on

How do you declare a "MustOverride" Constant?

Okay, I'm painfully new to TRUE OOP programming, and am working with inheritance.  I have a constant that I want each child class to be forced to set, so that in the base class a common method can be run that uses the value as set by its children.

I've tried the following:

Protected MustOverride Const Foo As Long

But needless to say, VB.Net no likey.  

I've come to the conclusion that I can create a regular variable in the base class, then make a required sub that "sets" the value of the variable, but this definitely feels like a hack.

Suggestions?
Visual Basic.NET.NET Programming

Avatar of undefined
Last Comment
Javin007

8/22/2022 - Mon
Javin007

ASKER
Update:  I've now found that I can make a "MustInherit" ReadOnly Property, but that still also feels hackish.
ASKER CERTIFIED SOLUTION
kaufmed

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Javin007

ASKER
Bummer.  This is considered the "right" way to do it?
SOLUTION
kaufmed

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
kaufmed

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Javin007

ASKER
Thanks!
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes