Solved

Unions?

Posted on 1998-06-10
10
375 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
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

Technology Partners: 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!

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

688 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