Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Significance of an ampersand in VB6 function name?

Tags:

vb6

sigils

I just got a bunch of legacy VB6 (!) code dumped on me and I keep seeing functions declared with an ampersand at the end of the name, for example, Private Declare Function ShellExecute& . . ..

I've been unable to find an answer to the significance of this, nor have I been able to detect any pattern in use or signature of the functions that have been named thusly.

Anyone know if those trailing ampersands mean anything to the compiler, or at least if there's some convention that I'm missing? So far, I'm writing it off as a strange programmer, but I'd like to know for sure if there's any meaning behind it.

like image 525
Ickster Avatar asked Feb 21 '12 06:02

Ickster


2 Answers

It means that the function returns a Long (i.e. 32-bit integer) value.

It is equivalent to

Declare Function ShellExecute(...) As Long

The full list of suffixes is as follows:

Integer %
Long    &
Single  !
Double  #
Currency @
String  $
like image 59
Philip Sheard Avatar answered Sep 27 '22 20:09

Philip Sheard


As Philip Sheard has said it is an indentifier type for a Long. They are still present in .Net, see this MSDN link and this VB6 article

From the second article:

The rules for forming a valid VB variable name are as follows:

(1) The first character must be a letter A through Z (uppercase or lowercase letters may be used). Succeeding characters can be letters, digits, or the underscore (_) character (no spaces or other characters allowed).

(2) The final character can be a "type-declaration character". Only some of the variable types can use them, as shown below:

Data Type  Type Declaration Character  

String         $  
Integer        %  
Long           &  
Single         !  
Double         #  
Currency       @    

Use of type-declaration characters in VB is not encouraged; the modern style is to use the "As" clause in a data declaration statement.

like image 22
Mark Hall Avatar answered Sep 27 '22 22:09

Mark Hall