What is difference between Command$ and Command in VB 6?
MsgBox Command$
MsgBox Command
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Any time you see a
$after a function in VB 6, it means that the function is aStringversion, meaning it returns a value of typeString. The version without the dollar sign is aVariantfunction, which of course means it returns a value of typeVariant.In general, you should always prefer the
Stringversions over theVariantversions.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:
indicates a variable named
namethat is of typeString. The alternative (and preferred!) notation is:In case you’re dealing with legacy code where these appear, here’s the entire list for completeness: