0
我的目標是讓代碼在任何地方隨機發出1到30秒鐘的嗶聲。這是我的代碼到目前爲止:在VB中設置隨機定時器時間間隔
Public Class Form1
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Console.Beep()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Timer1.Stop()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Start()
End Sub
End Class
這會發出嗶嗶聲,每秒鐘。現在,我想更改Timer
間隔,以便在1到30秒之間隨機發出蜂鳴聲。也許稍後我會爲用戶添加選項來定義邊界,但現在,1和30是好數字。我只是不知道如何將隨機數應用到我的計時器間隔。