Significance of an ampersand in VB6 function name?

时间秒杀一切 提交于 2019-11-29 17:08:10

问题


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.


回答1:


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  $



回答2:


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.



来源:https://stackoverflow.com/questions/9373135/significance-of-an-ampersand-in-vb6-function-name

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!