你的问题真的很有趣。我认为现在所需的功能已在下面完全实现。我测试了它,我相信它有效。
假设您使用 Button1 触发整个功能,并且您想使用我们拥有的 Timer 组件:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim seconds As New Integer()
Dim minutes As New Integer()
seconds = System.DateTime.Now.TimeOfDay.Seconds
minutes = System.DateTime.Now.TimeOfDay.Minutes
Dim firstOccurrence As TimeSpan = TimeSpan.Zero
Do
If seconds.Equals(60) Then
Exit Do
Else
seconds = seconds + 1
firstOccurrence = firstOccurrence + TimeSpan.FromSeconds(1)
End If
Loop
Do
If minutes.Equals(59) Or minutes.Equals(29) Then
Exit Do
Else
minutes = minutes + 1
firstOccurrence = firstOccurrence + TimeSpan.FromMinutes(1)
End If
Loop
Timer1.Interval = (((firstOccurrence.Minutes) * 60) + ((firstOccurrence.Seconds))) * 1000
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) 处理 Timer1.Tick
'execute your code here
Timer1.Interval = 30 * 60 * 1000
End Sub