這場景,我有三個NumericUpDown
爲第二,分鐘和小時值,而如果在NumericUpDown
即5
輸入一個數字,它會被轉換爲所以我的Timer
可以讀取它5秒。我試圖讓每一個間隔調度,這是我的代碼:VB.NET如何添加入庫時間定時器Inteval
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label13.Text = TimeSpan.FromSeconds(Form3.NumericUpDown1.Text).TotalMilliseconds
Label14.Text = TimeSpan.FromMinutes(Form3.NumericUpDown2.Text).TotalSeconds
Label15.Text = TimeSpan.FromHours(Form3.NumericUpDown3.Text).TotalMinutes
Dim times() As String = {Label13.Text, Label14.Text, Label15.Text}
For Each time In times
Dim interval As TimeSpan = TimeSpan.Parse(time)
Timer1.Interval = interval
MsgBox("hey")
Next
End Sub
它在Timer1.Interval = interval
,說Timespan cannot be converted to Integer
有錯誤,我想不出什麼辦法來解決這個問題,你可以幫幫我? TIA〜!
你想在這裏什麼也不是那麼清楚。假如你的'NumericUpDown1.Text = 5','NumericUpDown2.Text = 15','NumericUpDown3.Text = 25',你希望它的行爲如何? – Ian