Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
476 views
in Technique[技术] by (71.8m points)

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

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

MsgBox Command$
MsgBox Command
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

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


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$

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...