Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Mac Mac is offline
external usenet poster
 
Posts: 213
Default Declaration w initialization - for dummies

Hello,

how do I declare and initialize at the same time? If I cannot use 'Dim
boolVar as boolean = false' - what is correct, then?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Declaration w initialization - for dummies

Hi

When you declare a boolean variable, it is False by default. Just use:

Sub Test
Dim boolVar as Boolean
Debug.Print boolVar' See the value of the variable in the immediate window
End Sub

Regards,
Per

"Mac" skrev i meddelelsen
...
Hello,

how do I declare and initialize at the same time? If I cannot use 'Dim
boolVar as boolean = false' - what is correct, then?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Declaration w initialization - for dummies

Hi Mac

--Unlike many other languages, VBA or even VB does not allow you to
initialize variables; this must be done with a separate executable statement.

--Each variable does have a default initialization value. Numeric variable
types are initialized to zero, Strings are initialized to "" or vbNullString,
Booleans are initialized to False and so on...

--VB .NET allows you to initialize variables in the declaration.
Dim x As Single = 1.23
Dim txt As String = "This is a test"


--
Jacob


"Mac" wrote:

Hello,

how do I declare and initialize at the same time? If I cannot use 'Dim
boolVar as boolean = false' - what is correct, then?

  #4   Report Post  
Posted to microsoft.public.excel.programming
Mac Mac is offline
external usenet poster
 
Posts: 213
Default Declaration w initialization - for dummies

I thought as much, glad to have it confirmed. Thank you!

"Jacob Skaria" wrote:

Hi Mac

--Unlike many other languages, VBA or even VB does not allow you to
initialize variables; this must be done with a separate executable statement.

--Each variable does have a default initialization value. Numeric variable
types are initialized to zero, Strings are initialized to "" or vbNullString,
Booleans are initialized to False and so on...

--VB .NET allows you to initialize variables in the declaration.
Dim x As Single = 1.23
Dim txt As String = "This is a test"


--
Jacob


"Mac" wrote:

Hello,

how do I declare and initialize at the same time? If I cannot use 'Dim
boolVar as boolean = false' - what is correct, then?

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
how to use for dummies audrey nurse New Users to Excel 2 July 5th 21 12:23 PM
VBA for Dummies? Meenie Excel Discussion (Misc queries) 3 April 7th 08 06:45 PM
Macros for dummies?? NerdGirl New Users to Excel 1 January 18th 08 09:38 PM
Macros for Dummies Valerie Excel Discussion (Misc queries) 9 April 16th 07 12:26 PM
TreeView for Dummies bach Excel Programming 1 November 2nd 05 06:54 PM


All times are GMT +1. The time now is 06:43 PM.

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

About Us

"It's about Microsoft Excel"