Solved

Unions?

Posted on 1998-06-10
10
372 Views
Last Modified: 2010-05-03
Union is not possible in Visual Basic, I think, how do you get around this then?
0
Comment
Question by:k_chen
10 Comments
 
LVL 4

Expert Comment

by:zsi
ID: 1463010
Strike.
0
 

Author Comment

by:k_chen
ID: 1463011
Please, serious answers please.
0
 
LVL 6

Expert Comment

by:clifABB
ID: 1463012
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.
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 6

Expert Comment

by:clifABB
ID: 1463013
In C++:
Union {
float f;
int n;
} UDF

In VB:
Type UDF
  f As Single
  n As Integer
End Type
0
 
LVL 6

Expert Comment

by:clifABB
ID: 1463014
Also, unnamed UDTs are not allowed.
0
 
LVL 1

Expert Comment

by:JayMerritt
ID: 1463015
Could you be referring to UNION not existing in Access SQL?
0
 

Author Comment

by:k_chen
ID: 1463016
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?
0
 
LVL 6

Accepted Solution

by:
clifABB earned 40 total points
ID: 1463017
You are absolutely correct.  Constants aren't allowed in UDTs.

Why did you reject my answer?  It is correct.  (It wasn't the rubber duck joke, was it?)

Perhaps it was an oversight so I will submit this as an answer.
0
 
LVL 6

Expert Comment

by:clifABB
ID: 1463018
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.
0
 

Author Comment

by:k_chen
ID: 1463019
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.
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question