Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
UserForm initialize | Excel Programming | |||
userform initialize | Excel Programming | |||
Initialize macro | Excel Programming | |||
Initialize variable | Excel Programming | |||
Initialize data in new row? | Excel Programming |