Question

I have a program set up that has 3 numericupdowns. Their names are secondsN, minutesN, and hoursN. I want to set a timer based on the values of the numericupdowns.

Example: if secondsN has a value of 3 then I want the clock to be set to 3 seconds which I think is 3000 milliseconds.

so how can I do this?

Thanks for your help!

Was it helpful?

Solution

You can combine them into a TimeSpan. Then use the TotalMilliseconds property off of that.

int numberOfHours, numberOfMinutes, numberOfSeconds;
var timeSpan = new TimeSpan(numberOfHours, numberOfMinutes, numberOfSeconds);
myTimer.Interval = timeSpan.TotalMilliseconds;

OTHER TIPS

How about

Timespan ts = new Timespan(
              Convert.ToInt32(value_from_hoursN), 
              Convert.ToInt32(value_from_minutesN),
              Convert.ToInt32(value_from_secondsN));

Then double interval  = ts.TotalMilliSeconds;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top