Weird Overflow

I know this is the .net forums, but I don't know where else to turn, please help.
I have a class in vb6 and I keep getting an overflow error, please help.
strDateCreated = VBA.Format$(strNewValue, "MMDDYYYY")
Explanation: strDateCreated is a private variable in my class. The actual property is:
public property get datecreated() as string
datecreated=strdatecreated
end property
public property let datecreated(strNewValue) as string
strDateCreated=VBA.Format$(strNewValue, "MMDDYYYY") '//this is the line that causes the overflow error.
end property
In a form module I have:
if nt.datecreated="" then nt.datecreated= Now
Thanks in advance
[708 byte] By [bud1024] at [2007-12-16]
# 1

Its been a while since I used VB6 and I don't have it installed in front of me, but here are a few of my observations:

1. I believe the format string is usually lower case ("mmddyyyy"). Not sure if its case sensitive though.

2. You might just double check the value of strNewValue after entering that property but before hitting that line just to make sure that it is a string and will actually result in a date. In fact I would add something like IsDate(strNewValue) to guard against passing a bad string to Format$.

3. I'm probably reaching now, but I'd also check to make sure that strDateCreated is declared as a string.

Hope some of that helps.

Regards,
Patrick Baker
Microsoft Visual Basic Deployment & Designer Team


This posting is provided "AS IS" with no warranties, and confers no rights.

PatrickBaker at 2007-9-9 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 2
I wouldn't call the format command like that. Try this.
strDateCreated=Format(strNewValue, "MMDDYYYY")
Note, that there is a difference between "MMDDYYYY" and "mmddyyyy", and will return a different string. Lookup the format command to see what each character does.
Also, make sure strDateCreated is a string.
StrNewValue has to somewhat be a date string that the format command is going to be able to format.
If strNewValue is something like "5th of June of Year 2005" it's not going to be able to format that properly. Howver, something like "2005.23.03" should format just fine.

Dustin.

Dustin_H at 2007-9-9 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 3

Hi,

Dustin_H is right. the difference is between the case. "mm" returns minutes in time while "MM' returns numeric month and "MMMM" returns a complete word month and "MMM" returns a month's abbreviations...

cheers,

Paul June A. Domag

PaulDomag at 2007-9-9 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 4
When I step through the program's execution, the strNewValue has a value of Now (whatever the current value is), and the "MMDDYYYY" has a value of, for example, 08042005.
bud1024 at 2007-9-9 > top of Msdn Tech,Visual Basic,Visual Basic General...