这是一个场景,我有三个NumericUpDown
表示秒,分和小时的值,如果在NumericUpDown
中输入了一个数字,即5
,它将被转换至5000 ms
,以便Timer
可以将其读取为5秒。我试图为每个间隔制作一个调度程序,这是我的代码:
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〜!
答案 0 :(得分:0)
以下是一些让您了解当前错误的建议。
Dim tsTest As TimeSpan = TimeSpan.FromSeconds(NumericUpDownTest.Value)
Label1.Text = tsTest.TotalSeconds.ToString("n0")
Timer1.Interval = CInt(tsTest.TotalMilliseconds)
从只做几秒开始,当代码工作时,看看你是否可以添加其他代码。
答案 1 :(得分:0)
试试这个
1 52 Hayden Smith 18:16 15 M Berlin
2 54 Mark Puleo 18:25 15 M Berlin
3 97 Peter Warrington 18:26 29 M New haven
4 305 Matt Kasprzak 18:53 33 M Falls Church
5 272 Kevin Solar 19:17 16 M Sterling
6 394 Daniel Sullivan 19:35 26 M Sterling
7 42 Kevan DuPont 19:58 18 M Boylston
8 306 Chris Goethert 20:00 43 M Falls Church
9 262 James Sullivan 20:12 28 M Sterling
10 348 Bill Gaudere 20:17 54 M Hudson
11 13 Travis Wheeler 20:23 31 M Clinton
12 69 Eric Anderson 20:34 54 M Clinton
13 341 Alex Teixeira 20:46 0 M Clinton
14 112 James Long 20:50 38 M 0
15 279 Nate Richards 21:31 17 M Berlin
......................................................