Link to home
Start Free TrialLog in
Avatar of daghoff
daghoff

asked on

How to define a new variabel type in VB.NET

Let me explain with an example.

By variabel type I mean f. ex. Boolean, String, Integer etc....

A variabel defined as Boolean can only hold the values True or False. Asigning anything else to it would result in a runtime error and/or a syntax error.

I would like to define a variabel type that we could call BolleanExt. A variabel defined as BooleanExt can only hold the values True, False or None. Asigning any other value will result in an error.

Another example could be a variable type that can only hold the three values Abc, Def or Ghi.


Can someone give me an exaple code on how this new variabel type could be defined so I can declare variabels from it in my code the same way I declare any other ordinary variabel like: Dim var1 As String.
SOLUTION
Avatar of strickdd
strickdd
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of daghoff
daghoff

ASKER

The Enum concept looks interesting, but I would like to see how it is being done in a class. I have searched Internet for hours trying to find good examples of that without luck. I know it is out there somewhere, but the problem is to construct searches that gives me what I want. That’s way I turn to EE.

Please give me a good example code or a link to something that explains this in a simple way.
> but I would like to see how it is being done in a class.
Not sure what you mean there. Using Enum within a class?
Avatar of daghoff

ASKER

Sorry for not expressing myself in a clear way.  Enum or not Enum is not relevant.

My question is how to define a new variabel type within a class in the simplest way using whatever that is needed.

I have no ide how this is to be done. This is a black box for me that I try to get inside.

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial