Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Combine Command button with timer.... plz help

RooftopRooftop Posts: 10Member
Hi all, i want to make simulation of my handphone in Visual Basic 6.0
So the first command i must make is how to turn on and turn off it.
But i want to make it like my handphone, if i hold the Cancel button for about 3 second then it will automaticly turn off (when my sistem condition is on) and turn it on while my sistem condition is off.
So i quess i need timer and command button.But it's my first time to use timer so anyone can help me please....

Thank you for your repply.

Comments

  • BarkeeperBarkeeper Posts: 335Member
    : Hi all, i want to make simulation of my handphone in Visual Basic 6.0
    : So the first command i must make is how to turn on and turn off it.
    : But i want to make it like my handphone, if i hold the Cancel button for about 3 second then it will automaticly turn off (when my sistem condition is on) and turn it on while my sistem condition is off.
    : So i quess i need timer and command button.But it's my first time to use timer so anyone can help me please....
    :
    : Thank you for your repply.
    :
    :

    Check out the "MouseDown"-Event.

    Small Example:
    Start a new project and add a Command-Button and a Timer to the Form.
    Set the Enabled-Property of the Timer to false and the Intervall to 3000
    (Interval is the Time between two Timer-Events in Milliseconds, so 3000=3 Seconds
    Add following code:

    Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

    Timer1.Enabled = True

    End Sub

    Private Sub Timer1_Timer()

    MsgBox "The Button was held down for 3 seconds"
    [b]Put here your Code you want to be processed like "App.Shutdown" or "App.Boot"[/b]
    Timer1.Enabled=False

    End Sub

    Run the Programm and click on the Command-Button and hold it down. There should popup a Message-Box.
    ------------------------------------------
    Only stupidity of mankind and the universe
    are infinite, but i'm not sure concerning
    the universe. A. Einstein

  • RooftopRooftop Posts: 10Member
    : : Hi all, i want to make simulation of my handphone in Visual Basic 6.0
    : : So the first command i must make is how to turn on and turn off it.
    : : But i want to make it like my handphone, if i hold the Cancel button for about 3 second then it will automaticly turn off (when my sistem condition is on) and turn it on while my sistem condition is off.
    : : So i quess i need timer and command button.But it's my first time to use timer so anyone can help me please....
    : :
    : : Thank you for your repply.
    : :
    : :
    :
    : Check out the "MouseDown"-Event.
    :
    : Small Example:
    : Start a new project and add a Command-Button and a Timer to the Form.
    : Set the Enabled-Property of the Timer to false and the Intervall to 3000
    : (Interval is the Time between two Timer-Events in Milliseconds, so 3000=3 Seconds
    : Add following code:
    :
    : Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    :
    : Timer1.Enabled = True
    :
    : End Sub
    :
    : Private Sub Timer1_Timer()
    :
    : MsgBox "The Button was held down for 3 seconds"
    : [b]Put here your Code you want to be processed like "App.Shutdown" or "App.Boot"[/b]
    : Timer1.Enabled=False
    :
    : End Sub
    :
    : Run the Programm and click on the Command-Button and hold it down. There should popup a Message-Box.
    : ------------------------------------------
    : Only stupidity of mankind and the universe
    : are infinite, but i'm not sure concerning
    : the universe. A. Einstein
    :
    : thanks for the repply, but when i try it i don't need to hold it down to quit my program....
    Maybe because when i click the command button, the timer count to 3 seconds(3000ms) then execute my program, so it doesn't care about the hold down or just release it immediately

  • Mike_AB1Mike_AB1 Posts: 49Member
    : : : Hi all, i want to make simulation of my handphone in Visual Basic 6.0
    : : : So the first command i must make is how to turn on and turn off it.
    : : : But i want to make it like my handphone, if i hold the Cancel button for about 3 second then it will automaticly turn off (when my sistem condition is on) and turn it on while my sistem condition is off.
    : : : So i quess i need timer and command button.But it's my first time to use timer so anyone can help me please....
    : : :
    : : : Thank you for your repply.
    : : :
    : : :
    : :
    : : Check out the "MouseDown"-Event.
    : :
    : : Small Example:
    : : Start a new project and add a Command-Button and a Timer to the Form.
    : : Set the Enabled-Property of the Timer to false and the Intervall to 3000
    : : (Interval is the Time between two Timer-Events in Milliseconds, so 3000=3 Seconds
    : : Add following code:
    : :
    : : Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    : :
    : : Timer1.Enabled = True
    : :
    : : End Sub
    : :
    : : Private Sub Timer1_Timer()
    : :
    : : MsgBox "The Button was held down for 3 seconds"
    : : [b]Put here your Code you want to be processed like "App.Shutdown" or "App.Boot"[/b]
    : : Timer1.Enabled=False
    : :
    : : End Sub
    : :
    : : Run the Programm and click on the Command-Button and hold it down. There should popup a Message-Box.
    : : ------------------------------------------
    : : Only stupidity of mankind and the universe
    : : are infinite, but i'm not sure concerning
    : : the universe. A. Einstein
    : :
    : : thanks for the repply, but when i try it i don't need to hold it down to quit my program....
    : Maybe because when i click the command button, the timer count to 3 seconds(3000ms) then execute my program, so it doesn't care about the hold down or just release it immediately
    :
    :

    You need to disable timer on MouseUp event this will help to avoid from unwanted execution.
    Also disable timet on the form_mousemove event:

    Private Sub cmdCancel_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Timer1.Interval = 3000
    Timer1.Enabled = True

    End Sub


    Private Sub cmdCancel_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Timer1.Enabled = False
    End Sub


    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

    '''This will prevent execution if ueser will move cursor out of button while holding the button
    Timer1.Enabled = False

    End Sub


    Private Sub Timer1_Timer()

    Timer1.Enabled = False
    Call MsgBox("The Button was held down for 3 seconds")

    End Sub

    Mike.
  • RooftopRooftop Posts: 10Member
    : : : : Hi all, i want to make simulation of my handphone in Visual Basic 6.0
    : : : : So the first command i must make is how to turn on and turn off it.
    : : : : But i want to make it like my handphone, if i hold the Cancel button for about 3 second then it will automaticly turn off (when my sistem condition is on) and turn it on while my sistem condition is off.
    : : : : So i quess i need timer and command button.But it's my first time to use timer so anyone can help me please....
    : : : :
    : : : : Thank you for your repply.
    : : : :
    : : : :
    : : :
    : : : Check out the "MouseDown"-Event.
    : : :
    : : : Small Example:
    : : : Start a new project and add a Command-Button and a Timer to the Form.
    : : : Set the Enabled-Property of the Timer to false and the Intervall to 3000
    : : : (Interval is the Time between two Timer-Events in Milliseconds, so 3000=3 Seconds
    : : : Add following code:
    : : :
    : : : Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    : : :
    : : : Timer1.Enabled = True
    : : :
    : : : End Sub
    : : :
    : : : Private Sub Timer1_Timer()
    : : :
    : : : MsgBox "The Button was held down for 3 seconds"
    : : : [b]Put here your Code you want to be processed like "App.Shutdown" or "App.Boot"[/b]
    : : : Timer1.Enabled=False
    : : :
    : : : End Sub
    : : :
    : : : Run the Programm and click on the Command-Button and hold it down. There should popup a Message-Box.
    : : : ------------------------------------------
    : : : Only stupidity of mankind and the universe
    : : : are infinite, but i'm not sure concerning
    : : : the universe. A. Einstein
    : : :
    : : : thanks for the repply, but when i try it i don't need to hold it down to quit my program....
    : : Maybe because when i click the command button, the timer count to 3 seconds(3000ms) then execute my program, so it doesn't care about the hold down or just release it immediately
    : :
    : :
    :
    : You need to disable timer on MouseUp event this will help to avoid from unwanted execution.
    : Also disable timet on the form_mousemove event:
    :
    : Private Sub cmdCancel_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    : Timer1.Interval = 3000
    : Timer1.Enabled = True
    :
    : End Sub
    :
    :
    : Private Sub cmdCancel_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    : Timer1.Enabled = False
    : End Sub
    :
    :
    : Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    :
    : '''This will prevent execution if ueser will move cursor out of button while holding the button
    : Timer1.Enabled = False
    :
    : End Sub
    :
    :
    : Private Sub Timer1_Timer()
    :
    : Timer1.Enabled = False
    : Call MsgBox("The Button was held down for 3 seconds")
    :
    : End Sub
    :
    : Mike.
    :
    Yayyy it works... thank you very much ^^ you're my savior

Sign In or Register to comment.