Support Forums
[Question] Countdown 2 - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18)
+---- Forum: Visual Basic and the .NET Framework (https://www.supportforums.net/forumdisplay.php?fid=19)
+---- Thread: [Question] Countdown 2 (/showthread.php?tid=4037)



[Question] Countdown 2 - p1g 0wnz - 12-29-2009

I know some here probably would say just edit your old post. But that's useless because people usually just think they already helped me. But anyway my new question is here..


1. Is there a way i could make my countdown beep once it reached 0?

2. How can i make it you can't do -1 (or any number) Because if they do that they go up instead of going down :/


RE: [Question] Countdown 2 - Digital-Punk - 12-29-2009

Code:
Private Sub Button1_Click(ByVal sender As System.Object, _
            ByVal e As System.EventArgs) Handles Button1.Click
        Dim frequency As Integer = 10000
        Dim duration As Integer = 5000

        Console.Beep(frequency, duration)
    End Sub

    Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As  _
        System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
        'allows only numbers
        'and backspace
        If (e.KeyChar < "0" OrElse e.KeyChar > "9") _
            AndAlso e.KeyChar <> ControlChars.Back Then
            e.Handled = True
        End If
    End Sub

you get the idea


RE: [Question] Countdown 2 - dunlop03 - 12-29-2009

Theres a much simpler way. What are you using to display ur countdown ?
Lets say your using a label.

Code:
If label1.text = "0" Then
            Console.Beep(1000, 1000)
        End If



RE: [Question] Countdown 2 - p1g 0wnz - 12-29-2009

Dunlop, where do i add that code?

But thanks both of you guys Big Grin I'll try it out.


RE: [Question] Countdown 2 - dunlop03 - 12-29-2009

Put it in timer1_tick, im uploading one i made just there now onto youtube , ill post it here in 2 min , if you want the code let me know.

Code:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
      If label1.text = "0" Then
            Console.Beep(1000, 1000)
        End If
      End If

Here it is

[yt]http://www.youtube.com/watch?v=hnNsO_NGVoQ[/yt]
Althought i put a .wav file in my project "Resources" and coded it like this:

Code:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If Label1.Text = "0" Then
            My.Computer.Audio.Play(My.Resources.heart_monitor, AudioPlayMode.BackgroundLoop)
            Timer1.Stop()
        End If
    End Sub



RE: [Question] Countdown 2 - p1g 0wnz - 12-29-2009

All i need is how you add music :S, I know the rest Big Grin Tyvm dunlop you been very helpful. I'd rep if you knew how to and if i would been able to


RE: [Question] Countdown 2 - dunlop03 - 12-29-2009

np m8

Get a .WAV file

Goto vb, double click "My Project" , select "Resources" , simply drag and drop the .WAV file into the "Resources"

Now you can use this to play that file (heart_monitor , is my .WAV file name) , replace that with your file name:

Code:
My.Computer.Audio.Play(My.Resources.heart_monitor, AudioPlayMode.BackgroundLoop)