Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

MsgBox Command$
MsgBox Command
like image 535
faressoft Avatar asked Dec 24 '10 15:12

faressoft


People also ask

What is a command in VB?

When referring to a programming language, a command is a unique word/keyword used to perform a specific operation. Unlike variables, which are named and defined within your code, command names are defined by the programming language itself and cannot be changed.

What is the difference between sub and function in VB net?

A sub performs a task but does not return a value. A function returns a value of the tasks performed. Subs can be recalled from anywhere in the program and in multiple types. Functions are called by a variable.

How do I run Visual Basic from command prompt?

Invoke the Developer Command Prompt for Visual Studio. At the command line, type vbc.exe sourceFileName and then press ENTER.

What is Sub Main in VB net?

A Sub procedure is a separate set of codes that are used in VB.NET programming to execute a specific task, and it does not return any values. The Sub procedure is enclosed by the Sub and End Sub statement.


2 Answers

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
like image 157
Cody Gray Avatar answered Oct 08 '22 23:10

Cody Gray


They both return the same string but Command returns the string in a Variant.

There are actually quite a few VB functions that do this. The $ at the end indicates the function returns a string while the counterparts return variants.

like image 24
Jonathan Wood Avatar answered Oct 09 '22 01:10

Jonathan Wood