Solved

Unions?

Posted on 1998-06-10
10
371 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

862 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now