Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Double variables initialize to zero??

Hi,

I've got an array of doubles and i want to check that they have not
been initialized.

However, the following code returns a message box with false and
outputting the variable foo gives 0.
Is this behaviour intended, how can I work around it?

Thanks,
Mark

sub test()

dim foo as double
msgbox isnull(foo)

end sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Double variables initialize to zero??

Mark,
When a procedure begins running, a numeric variable is initialized to zero
and Variant variables are initialized to Empty.
IsNull can be misleading as it will only tell you the if the condition that exists
is the absence of any value. For instance... IsNull(CheckBox1.Value).
Note that empty, zero and "" are not null conditions.

However, if are you asking if an array has been dimensioned? Then ...
Sub ReadyOrNot()
Dim d() As Double
Dim blnReady As Boolean
' ReDim d(0 To 1000)
On Error Resume Next
blnReady = UBound(d) -9999999
On Error GoTo 0
MsgBox blnReady
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware




wrote in message
Hi,
I've got an array of doubles and i want to check that they have not
been initialized.
However, the following code returns a message box with false and
outputting the variable foo gives 0.
Is this behaviour intended, how can I work around it?
Thanks,
Mark

sub test()
dim foo as double
msgbox isnull(foo)
end sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 274
Default Double variables initialize to zero??

In addition to Jim's idea of using a variant which is later
initialized (dimensioned) to be an array, another possible work-around
is to maintain a boolean flag (which is automatically initialized to
false) and set the flag equal to true when the initialization code is
run.

Hth,

John Coleman

On Mar 22, 10:01 am, "
wrote:
Hi,

I've got an array of doubles and i want to check that they have not
been initialized.

However, the following code returns a message box with false and
outputting the variable foo gives 0.
Is this behaviour intended, how can I work around it?

Thanks,
Mark

sub test()

dim foo as double
msgbox isnull(foo)

end sub



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
UserForm initialize Arne Hegefors Excel Programming 8 September 8th 06 01:48 PM
userform initialize Patrick Simonds Excel Programming 1 August 4th 06 11:14 PM
Initialize macro Tom Jung Excel Programming 1 October 31st 05 04:04 AM
Initialize variable hotherps[_128_] Excel Programming 2 August 26th 04 02:38 PM
Initialize data in new row? Ken[_12_] Excel Programming 1 August 9th 03 05:13 PM


All times are GMT +1. The time now is 12:04 PM.

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"