View Full Version : Overflow error.
Chenix
02-13-2014, 12:51 PM
Hi. Fairly new to VBA coding and having trouble with this macro. Gives me an overflow error, but since I am new I have no idea what that is or how to fix it. Any help?11279
westconn1
02-13-2014, 01:17 PM
overflow error means a value is being assigned to a variable that is not big enough to hold the value, change the type of your variable, or use type casting for calculations
post which code is causing the error and when it happens
Chenix
02-13-2014, 01:18 PM
Here it is.
Private Sub MathGame()
'Manages the clocl while testing. Calls scoring procedures when test is over.
Dim numSeconds As Integer
Dim nextTime As Date
Const TIMEALLOWED = 60
numSeconds = DateDiff("s", curDate, Now)
'---------------------
'Start the clock.
'---------------------
Range("Clock").Value = TIMEALLOWED - numSeconds
nextTime = Now + TimeValue("00:00:01")
Application.OnTime EarliestTime:=nextTime, _
Procedure:="MathGameSheet.MathGame", Schedule:=True
westconn1
02-14-2014, 01:11 AM
what would be the value of curdate when the procedure runs, somthing over 9 hours in seconds is the maximum an integer can hold, try changing to a long
...nor does curDate appear to be defined/declared in the posted snippet. You are very most likely safe in declaring anything (save some particular args passed to API if present) you have as an Integer, as a Long.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.