ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Simple Declaration Question (https://www.excelbanter.com/excel-programming/339387-simple-declaration-question.html)

Andibevan[_4_]

Simple Declaration Question
 
If I want to declare values String1 and String2 as strings can I use the
following:-

Dim String1, String2 as String

Or do I need

Dim String1 as string, String2 as string?

Ta

Andi



DaveO

Simple Declaration Question
 
The difference between your 2 statements;

Statement 1 - Only declares String2 as a string. String1 would be considered
a Variant.

Statement 2 - Declares both as a string.

Not sure why this is the case, but I know that the first option doesn't
initaiate an instance of the property for the 1st variable.

HTH.

"Andibevan" wrote:

If I want to declare values String1 and String2 as strings can I use the
following:-

Dim String1, String2 as String

Or do I need

Dim String1 as string, String2 as string?

Ta

Andi




JE McGimpsey

Simple Declaration Question
 
From XL/VBA Help ("Declaring Variables"):

You can declare several variables in one statement. To specify a data
type, you must include the data type for each variable. In the
following statement, the variables intX, intY, and intZ are declared
as type Integer.

Dim intX As Integer, intY As Integer, intZ As Integer

In the following statement, intX and intY are declared as type
Variant; only intZ is declared as type Integer.

Dim intX, intY, intZ As Integer

You don't have to supply the variable's data type in the declaration
statement. If you omit the data type, the variable will be of type
Variant.


In article ,
"Andibevan" wrote:

If I want to declare values String1 and String2 as strings can I use the
following:-

Dim String1, String2 as String

Or do I need

Dim String1 as string, String2 as string?

Ta

Andi


Jim Thomlinson[_4_]

Simple Declaration Question
 
Check out this link. It expains everything you wanted to know about variables
declarations but were affraid to ask...

http://www.cpearson.com/excel/variables.htm
--
HTH...

Jim Thomlinson


"Andibevan" wrote:

If I want to declare values String1 and String2 as strings can I use the
following:-

Dim String1, String2 as String

Or do I need

Dim String1 as string, String2 as string?

Ta

Andi




Andibevan[_3_]

Simple Declaration Question
 
Ta

"Jim Thomlinson" wrote in message
...
Check out this link. It expains everything you wanted to know about
variables
declarations but were affraid to ask...

http://www.cpearson.com/excel/variables.htm
--
HTH...

Jim Thomlinson


"Andibevan" wrote:

If I want to declare values String1 and String2 as strings can I use the
following:-

Dim String1, String2 as String

Or do I need

Dim String1 as string, String2 as string?

Ta

Andi







All times are GMT +1. The time now is 07:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com