VB 6 中的 Command$ 和 Command 有什么区别? [英] What is difference between Command$ and Command in VB 6?

查看:45
本文介绍了VB 6 中的 Command$ 和 Command 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Command$ 和 VB 6 中的 Command 有什么区别?

What is difference between Command$ and Command in VB 6?

MsgBox Command$
MsgBox Command

推荐答案

任何时候在 VB 6 中看到一个函数后面有一个 $ ,就表示该函数是一个 String 版本,意味着它返回一个 String 类型的值.没有美元符号的版本是一个 Variant 函数,这当然意味着它返回一个 Variant 类型的值.

Any time you see a $ after a function in VB 6, it means that the function is a String version, meaning it returns a value of type String. The version without the dollar sign is a Variant function, which of course means it returns a value of type Variant.

一般来说,您应该总是更喜欢 String 版本而不是 Variant 版本.

In general, you should always prefer the String versions over the Variant versions.


如果美元符号出现在变量名之后而不是指定类型,它也意味着同样的事情.在这里,它是 BASIC 早期版本中必不可少的一个更大的速记类型声明字符"系列的一部分,但在 VB 6 出现时已经过时了.例如:


The dollar sign also means the same thing if it appears after a variable name in lieu of a specified type. Here, it's part of a larger family of shorthand "type declaration characters" that were necessary in earlier versions of BASIC, but firmly antiquated by the time even VB 6 arrived on the scene. For example:

Dim name$

表示一个名为name的变量,它的类型是String.替代(和首选!)符号是:

indicates a variable named name that is of type String. The alternative (and preferred!) notation is:

Dim name As String

如果您正在处理出现这些的遗留代码,这里是完整的完整列表:

In case you're dealing with legacy code where these appear, here's the entire list for completeness:

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

这篇关于VB 6 中的 Command$ 和 Command 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆