Community discussion forum

Freeze a Form of VB6 using timer control

  • 4 months ago
    Private Sub Command1_Click()
    Timer1.Enabled = Not Timer1.Enabled
    Command1.Caption = IIf(Timer1.Enabled, "Stop", "Start")
    Command1.Visible = False
    

    End Sub

    Private Sub Command2_Click() Form2.Hide Form1.Show End Sub

    Private Sub Form_Load() Timer1.Interval = 1000 Timer1.Enabled = False Command1.Caption = "Start" txtmin.Text = " ": txtsec.Text = " ": txthour.Text = " "

    End Sub

    Private Sub Timer1_Timer() If Val(txtsec.Text) > 0 Or Val(txtmin.Text) > 0 Or Val(txthour.Text) > 0 Then If txtmin.Text = 0 And txthour.Text > 0 Then _ txtmin.Text = 60: txthour.Text = txthour.Text - 1 If txtsec.Text = 0 And txtmin.Text > 0 Then _ txtsec.Text = 60: txtmin.Text = txtmin.Text - 1 txtsec.Text = txtsec.Text - 1

         End If
         Me.WindowState = vbMinimized
         End Sub
    

    Private Sub txthour_Change() If Val(txthour.Text) > 4 Then txthour.Text = " " End If End Sub

    Private Sub txtmin_Change() If Val(txtmin.Text) > 60 Then txtmin.Text = " " End If End Sub

    Private Sub txtsec_Change() If Val(txtsec.Text) > 60 Then txtsec.Text = " " End If End Sub

    Here I have written a code to make a countdown.... Now I want to do ,when the timer will stop,Form1.frm will load automatically closing Form2. So what portion of my code need the modification.... Plz give me the code.....

    Post was edited on 16/07/2009 10:19:42 Report abuse
  • 4 months ago
    Private Sub Command1_Click()
    Timer1.Enabled = Not Timer1.Enabled
    Command1.Caption = IIf(Timer1.Enabled, "Stop", "Start")
    Command1.Visible = False
    

    End Sub

    Private Sub Command2_Click() Form2.Hide Form1.Show End Sub

    Private Sub Form_Load() Timer1.Interval = 1000 Timer1.Enabled = False Command1.Caption = "Start" txtmin.Text = " ": txtsec.Text = " ": txthour.Text = " "

    End Sub

    Private Sub Timer1_Timer() If Val(txtsec.Text) > 0 Or Val(txtmin.Text) > 0 Or Val(txthour.Text) > 0 Then If txtmin.Text = 0 And txthour.Text > 0 Then _ txtmin.Text = 60: txthour.Text = txthour.Text - 1 If txtsec.Text = 0 And txtmin.Text > 0 Then _ txtsec.Text = 60: txtmin.Text = txtmin.Text - 1 txtsec.Text = txtsec.Text - 1

         End If
         Me.WindowState = vbMinimized
         End Sub
    

    Private Sub txthour_Change() If Val(txthour.Text) > 4 Then txthour.Text = " " End If End Sub

    Private Sub txtmin_Change() If Val(txtmin.Text) > 60 Then txtmin.Text = " " End If End Sub

    Private Sub txtsec_Change() If Val(txtsec.Text) > 60 Then txtsec.Text = " " End If End Sub

    Here I have written a code to make a countdown.... Now I want to do ,when the timer will stop,Form1.frm will load automatically closing Form2. So what portion of my code need the modification.... Plz give me the code.....

Post a reply

Enter your message below

Sign in or Join us (it's free).

Want to stay in touch with what's going on? Follow us on twitter!