Reputation: 2988
In visual basic .net is it possible to use the label1.text as the value for timer1.interval?
I've tried the following, unfortunately it isn't working.
Dim Try_Interval As Integer = My.Settings.Error_Millisec
Int32.TryParse(frmSettings.Lbl_Error_Millisec_Fin.Text, Try_Interval)
It says
An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in System.Windows.Forms.dll
Additional information: Value '0' is not a valid value for Interval. Interval must be greater than 0.
I've also tried to store it in the my.settings like the below code
Dim Try_Max As Integer = Convert.ToDouble(My.Settings.Error_Try)
Dim Try_Interval As Integer = My.Settings.Error_Millisec
Any suggestions?
Upvotes: 0
Views: 662
Reputation: 460018
Int32.TryParse
initializes the int parameter when it could parse the string to Int32
successfully, otherwise it will be 0. So either the string cannot be parsed because the format is invalid orit is "0"
. What is it's value?
The value frmSettings.Lbl_Error_Millisec_Fin.Text is 0, take note that I've taken that from another form.
An Int32 specifying the number of milliseconds before the Tick event is raised relative to the last occurrence of the Tick event. The value cannot be less than one.
So specify a value that is >= 1
.
Upvotes: 2
Reputation: 2370
You can get the interval set as follows:
Dim timerValue As Integer
Integer.TryParse(timerLabel.Text, timerValue)
Timer1.Interval = timerValue
Upvotes: 1