Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default 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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default 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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default 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







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
IF formula-simple question; simple operator Rich D Excel Discussion (Misc queries) 4 December 6th 07 03:36 PM
simple vba question Jonathan Cooper Excel Discussion (Misc queries) 4 February 10th 06 07:03 PM
Simple Simple Excel usage question BookerW Excel Discussion (Misc queries) 1 June 23rd 05 10:06 PM
simple question, hopefully a simple answer! Matt B Excel Programming 5 January 13th 04 08:43 PM
Simple VBA question Srdan Kovacevic Excel Programming 2 October 17th 03 05:06 PM


All times are GMT +1. The time now is 05:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"