Going out on a Date$

by Michael S. Kaplan, published on 2006/07/13 03:01 -04:00, original URI: http://blogs.msdn.com/b/michkap/archive/2006/07/13/664166.aspx


A quick nod to Alex Papadimoulis for his Daily WTF post Long Distance DATE$ing. :-)

There is very little that I could add to this gem, other than to say that most people never realized that the syntax would even work (they assume Date$ is a function or something). This is lucky for us or we might have a much more widespread problem....

And I was once doing a job for a company that had this very bug in a complex application that was a pretty awful nightmare (their use of Date$ was actually the least of their concerns!).

 

This post brought to you by d (U+0064, a.k.a. LATIN SMALL LETTER D)


Ben Cooke on 13 Jul 2006 1:51 PM:

What exactly *is* DATE$ from a syntactic point of view? I'm a bit fuzzy on VB syntax, but I thought things shaped like that were either string variables or functions that return strings; you can't assign to the latter, and you can't (as far as I'm aware) make "magic" variables that run code when you assign to them. Or can you?

BASIC has always struck me as being a little crazy, but this DATE$ thing outdoes all of the other "Huh?" incidents I've had.

Michael S. Kaplan on 13 Jul 2006 9:23 PM:

Well, Date$ is actually a property off of the VBA.DateTime module, and it has both a Get and a Let off of it -- so you can retrieve the current date and you can set it.

So, in a property call you can do anything you like, even if it is not a good idea. :-)

No argument on the crazy factor here....

Please consider a donation to keep this archive running, maintained and free of advertising.
Donate €20 or more to receive an offline copy of the whole archive including all images.

go to newer or older post, or back to index or month or day