Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default how to check that a var type date is initialized ??

Let's suppose a declaration like this

1. Set the static value

Call LastInputDate(#08/15/2005#)

2. Display the static value
MsgBox(LastInputDate)

Function LastInputDate (Optional dDate as date) as date
Static dLastDate as Date

If IsEmpty(dDate) then
LastInputDate = dLAstDate
Else
dLastDate = dDate
End Function.


This is never working since dDate contains allways "12:00:00 Am". How to
solve this ?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default how to check that a var type date is initialized ??

If you declare dLastDate as date, then it's initial value is 00:00:00.

Could you check for that?

Or you could declare it as a variant and continue to check using isempty().



François wrote:

Let's suppose a declaration like this

1. Set the static value

Call LastInputDate(#08/15/2005#)

2. Display the static value
MsgBox(LastInputDate)

Function LastInputDate (Optional dDate as date) as date
Static dLastDate as Date

If IsEmpty(dDate) then
LastInputDate = dLAstDate
Else
dLastDate = dDate
End Function.

This is never working since dDate contains allways "12:00:00 Am". How to
solve this ?


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default how to check that a var type date is initialized ??

Hi François'

Try changing dDate to variant and using the IsMissing function.

For example , the following worked for me:

Sub InitialiseIt() '
Call LastInputDate(#8/15/2005#)
End Sub

Sub DisplayIt()
MsgBox (LastInputDate)
End Sub

Function LastInputDate(Optional dDate) As Date
Static dLastDate As Date

If IsMissing(dDate) Then
LastInputDate = dLastDate
Else
dLastDate = dDate
End If
End Function


---
Regards,
Norman



"François" wrote in message
...
Let's suppose a declaration like this

1. Set the static value

Call LastInputDate(#08/15/2005#)

2. Display the static value
MsgBox(LastInputDate)

Function LastInputDate (Optional dDate as date) as date
Static dLastDate as Date

If IsEmpty(dDate) then
LastInputDate = dLAstDate
Else
dLastDate = dDate
End Function.


This is never working since dDate contains allways "12:00:00 Am". How to
solve this ?



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default how to check that a var type date is initialized ??

Oops. I confused dLastDate and dDate.

Another way is to use a date that won't be used:

Function LastInputDate(Optional dDate As Date = #12/31/9999#) As Date
Static dLastDate As Variant

If dDate = DateSerial(9999, 12, 31) Then
......



Dave Peterson wrote:

If you declare dLastDate as date, then it's initial value is 00:00:00.

Could you check for that?

Or you could declare it as a variant and continue to check using isempty().

François wrote:

Let's suppose a declaration like this

1. Set the static value

Call LastInputDate(#08/15/2005#)

2. Display the static value
MsgBox(LastInputDate)

Function LastInputDate (Optional dDate as date) as date
Static dLastDate as Date

If IsEmpty(dDate) then
LastInputDate = dLAstDate
Else
dLastDate = dDate
End Function.

This is never working since dDate contains allways "12:00:00 Am". How to
solve this ?


--

Dave Peterson


--

Dave Peterson
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
check spelling as you type dp New Users to Excel 5 February 3rd 10 07:00 PM
Check for error.type in same cell art Excel Worksheet Functions 2 May 13th 09 06:14 AM
how to convert date type to text type Steffen Excel Discussion (Misc queries) 3 July 17th 07 11:32 AM
ImageList must be initialized What-a-Tool Excel Programming 6 October 27th 04 12:39 AM
listbox value not initialized John Holland Excel Programming 2 November 25th 03 07:57 PM


All times are GMT +1. The time now is 11:35 AM.

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"