I'm using a timer from the timer class. There is a combobox with minute, hour, and day inside of it. The timer calls my GetTicks() method where if-thens are used so that based on the word in the combo box being displayed (combobox.text) an int value is returned:
For a time it was working fine, then I did something and now it feeds me an ArgumentOutOfRa nge error.
When I debug it takes me directly to my line:
and tells me to make sure my numbers are valid.
If I hard code an interval value such as:
The program runs and works properly, so it seems the problem is occuring when calling my GetTicks method, but I can't understand why.
Code:
Clock.Interval = GetTimeInTicks();
Clock.Tick += new EventHandler(TimerEventProcessor);
Clock.Start();
private int GetTimeInTicks()
{
string temp = Properties.Settings.Default.TimeMeasure;
int minute = 60000,
hour = 3600000,
day = 86400000;
if (temp == "Minute")
{
return minute;//number of ticks in a minute
}
else if (temp == "Hour")
{
return hour;//number of ticks in an hour
}
else if (temp == "Day")
{
return day;//number of ticks in a day
}
else
{
return 0;
}
}
Code:
Problem signature: Problem Event Name: CLR20r3 Problem Signature 01: ipinformer console ap.exe Problem Signature 02: 1.0.0.0 Problem Signature 03: 4cfa0c7c Problem Signature 04: System.Windows.Forms Problem Signature 05: 4.0.0.0 Problem Signature 06: 4ba1e14e Problem Signature 07: 423e Problem Signature 08: 4b Problem Signature 09: System.ArgumentOutOfRange OS Version: 6.1.7600.2.0.0.256.1 Locale ID: 1033 Additional Information 1: 0a9e Additional Information 2: 0a9e372d3b4ad19135b953a78882e789 Additional Information 3: 0a9e Additional Information 4: 0a9e372d3b4ad19135b953a78882e789 Read our privacy statement online: http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409 If the online privacy statement is not available, please read our privacy statement offline: C:\Windows\system32\en-US\erofflps.txt
Code:
Clock.Interval = GetTimeInTicks();
If I hard code an interval value such as:
Code:
Clock.Interval = 10000;
Comment