Link to home
Start Free TrialLog in
Avatar of k_chen
k_chen

asked on

Unions?

Union is not possible in Visual Basic, I think, how do you get around this then?
Avatar of zsi
zsi

Strike.
Avatar of k_chen

ASKER

Please, serious answers please.
The closest thing we have to unions is the user defined type.  Kind of like saying the closest we have to a battleship is a rubber duck.

Sorry, humour goes with the territory.
In C++:
Union {
float f;
int n;
} UDF

In VB:
Type UDF
  f As Single
  n As Integer
End Type
Also, unnamed UDTs are not allowed.
Could you be referring to UNION not existing in Access SQL?
Avatar of k_chen

ASKER

I'm referring to union as how ClifABB described it in C++. Not the SQL command. Another question on Visual Basic's flaw. I don't think it's possible to declare constants in Type Declartion, is it?
ASKER CERTIFIED SOLUTION
Avatar of clifABB
clifABB

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
By the way...
I've been pondering this all night.  Why would anyone want to declare a constant in a union, struct, or UDT?  It's a very inefficient use of memory.  Every time you construct using the union you would be creating a new copy of the constant, when a single constant, declared globally, would be much more efficient.
Avatar of k_chen

ASKER

I think the point of having a constant in a UDT is to encapsulate     data objects. You're right, it does not have any merit from efficiency point of view.