ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Clearing a date vaiable (https://www.excelbanter.com/excel-programming/328312-re-clearing-date-vaiable.html)

Alok

Clearing a date vaiable
 
Hi

Once you have a date variable defined
it will continue to return true to IsDate() function.

You can set the date to 0, to clear the date but that will still return true
to the IsDate function call.

"PSKelligan" wrote:

Hi all,
Hopefully a silly but fast question.

Sub myCode()
Dim myDate As Date

myDate = "" 'Syntax meant for a string...
While Not While Not (IsDate(myDate))
'Misc code here
Wend
End Sub


In the line, myDate = "", what would be the right way to empty this date
variable?
I tried myDate = Nothing and that did not work either.
--
Thanks,

Patrick


Bob Phillips[_6_]

Clearing a date vaiable
 
Sub myCode()
dim myDate As Date

myDate = Empty
While Not (IsDate(myDate))
'Misc code here
Wend


End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Alok" wrote in message
...
Hi

Once you have a date variable defined
it will continue to return true to IsDate() function.

You can set the date to 0, to clear the date but that will still return

true
to the IsDate function call.

"PSKelligan" wrote:

Hi all,
Hopefully a silly but fast question.

Sub myCode()
Dim myDate As Date

myDate = "" 'Syntax meant for a string...
While Not While Not (IsDate(myDate))
'Misc code here
Wend
End Sub


In the line, myDate = "", what would be the right way to empty this date
variable?
I tried myDate = Nothing and that did not work either.
--
Thanks,

Patrick





All times are GMT +1. The time now is 03:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com