Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the $ symbol do in VBA?

Tags:

types

vba

For example:

variable1=Dir$(some_path) 

vs.

variable1=Dir(some_path) 

What is the difference?

Why not just do:

variable1=string(Dir(some_path)) 
like image 485
Alex Gordon Avatar asked Aug 02 '10 15:08

Alex Gordon


People also ask

What does #if mean in VBA?

Description. The Microsoft Excel IF-THEN-ELSE statement can only be used in VBA code. It executes one set of code if a specified condition evaluates to TRUE, or another set of code if it evaluates to FALSE. The IF-THEN-ELSE statement is a built-in function in Excel that is categorized as a Logical Function.

What does <> represent in VBA?

The <> operator means c. Address Is Not Equal To firstAddress . In a C-style language this would be equivalent to c. Address != firstAddress .


2 Answers

Here is a Cheat Sheet for DataTypes

Variable End with:

$ : String % : Integer (Int16) & : Long (Int32) ! : Single # : Double @ : Decimal 

Start with:

&H : Hex &O : Octal 

Comparison between VB and VB.Net (reference)

Visual Studio .Net added Literal Types (reference)

Value End with: (For more complete list, refer the the reference)

S : Short (Int16) I : Integer (Int32) L : Long (Int64) F : Single R : Double D : Decimal 
like image 65
Gerhard Powell Avatar answered Sep 21 '22 21:09

Gerhard Powell


I think that the $ version returns a String, and the non $ version returns a variant.

Mid vs Mid$

http://forums.devarticles.com/microsoft-access-development-49/mid-function-vs-mid-26315.html

like image 44
Jason Evans Avatar answered Sep 22 '22 21:09

Jason Evans