Here's a little news that suprised the heck out of me. Did you know you can create Enumerations using reserved words in VB6? Neither did I. Imagine my suprise when all of a sudden my tested code stopped working, and I tracked it down to my Date function, which is supposed to return the date portion of the system time. Instead, Date would return 1. If I assigned Date to a date variable, I got a date of 12/31/1899! We tracked the problem to this:
Enum MPSTextBoxPasteType
AlphaNumeric
Date
Numeric
End Enum
The Date function had been replaced by the Date enum value of 1. Sure, I could have avoided the problem by qualifying the Date function with VBA.Date, but who does that?
If you want to have some fun with your fellow coders, place the following in a public module somewhere in your program:
Enum Gotcha
IsNumeric
IsEmpty
IsNull
Date
Time
Now
.
.
.
End Enum
...you get the idea. Anything that you would pass a value to, such as IsNumeric, all of a sudden won't compile, and things that don't require an argument, such as Now, return strange results.
I'm sure Microsoft will tell you it's a feature. I guess that's why everything is an object in .Net...so that you have to qualify everything and this won't happen. It just really suprised me that VB6 would allow you to use reserved words such as these as Enum values.
Just FYI.
Enum MPSTextBoxPasteType
AlphaNumeric
Date
Numeric
End Enum
The Date function had been replaced by the Date enum value of 1. Sure, I could have avoided the problem by qualifying the Date function with VBA.Date, but who does that?
If you want to have some fun with your fellow coders, place the following in a public module somewhere in your program:
Enum Gotcha
IsNumeric
IsEmpty
IsNull
Date
Time
Now
.
.
.
End Enum
...you get the idea. Anything that you would pass a value to, such as IsNumeric, all of a sudden won't compile, and things that don't require an argument, such as Now, return strange results.
I'm sure Microsoft will tell you it's a feature. I guess that's why everything is an object in .Net...so that you have to qualify everything and this won't happen. It just really suprised me that VB6 would allow you to use reserved words such as these as Enum values.
Just FYI.