?
Solved

Unions?

Posted on 1998-06-10
10
Medium Priority
?
376 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 120 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

752 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