Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OVerflow error I do not know why

Status
Not open for further replies.

zrazzaq

MIS
Apr 13, 2005
102
US
Hi I have the following:
Code:
Public Function ConvTime2(sSecc As String) As Date
 ConvTime2 = TimeSerial(0, 0, Eval(Replace(sSecc, ":", "*60+")))
End Function
I get an overflow error when something like this comes along:
ConvTime2("561:32")
Anyone has any suggestions. Thanks
Zishan
 
What do you send it to??? if integer or single, try going double???

But either way it shouldnt overflow since the result is 40k =/ do you add up to other results??? my guess would be the size of the variable you use....
 
Well the 561:32 means 561 minutes and 32 seconds which I need to convert to hours:minutes:seconds....Im using access to input into a table by code...but converting the value first then updating the table..
Thanks
Zishan
 
basically your converting into seconds and then you reconvert to hours, minutes, and then seconds....

Why do you do it like that...

wouldnt it be more straight forward if you kept the seconds and converted minutes to hours by dividing in 60 and then cutting off the decimals and multiplicating by 60 to get minutes.... ????

And it would probably not overflow since you would keep lower numbers.... 561 / 60 < 561 * 60

Just a thought....
 
You are getting an overflow because

561*60+32 = 33692

which exceeds the maximum value for an integer (32767).

Try this
Code:
ConvTime2 = TimeSerial(0, 0, Eval(Replace(sSecc, ":", "[COLOR=red][b].[/b][/color]*60+")))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top