954,551 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

What value type is Global in Visual Basic?

What value type is Global in Visual Basic?

If I have something defined like this:

Global ErrorStatus&


And I have know what data type this is. I have heard that the compiler sets the data type based on how it is used. Well, suppose I have this problem where I have to know what the default type it is because I am sending it to a C++ DLL. What type should I expect?

complete
Junior Poster
153 posts since Dec 2005
Reputation Points: 17
Solved Threads: 0
 

In the defination above, you will have a variable (ErrorStatus&), which is global to the entire project. So any form, module, control, or anything within your project will have access to the variable. It should also be noted, that the variable in your example, is of type LONG, and the reason it's a LONG is because of the &. If, however, you left off the &, and just left the variable as ErrorStatus, then the type would be defined as a variant by default... as far as I know, no other language recognizes the variant data type, but I'm not 100% on that.
Variants are crappy types of variables, and should only be used in rare instances, however, your example above is Not a variant, but a LONG....

Comatose
Taboo Programmer
Team Colleague
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
 

I don't use Global. I put all my public declarations in a Module:

Public ErrorStatus as Long

SCBWV
Junior Poster
125 posts since Apr 2007
Reputation Points: 40
Solved Threads: 24
 
Global ErrorStatus&

Use the varType function: it returns the variable type.

You can use it from the Immediate Window
---------------------------------------------------
?varType(ErrorStatus&)


That will return a numerical value. Then you consult your MSDN documentation to see what type corresponds with that numerical value.

Hank

hkdani
Posting Pro in Training
435 posts since Nov 2007
Reputation Points: 49
Solved Threads: 47
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You