VB6.0 How to create a momentary push button

  • 14 years ago

    Need to create a momentary push button in VB for a touch screen monitor. As long as the user pushes a button, an output bit will be set high until the button is released.

    How can this be implemented? Thanks.

     

    N

  • 14 years ago

    Many views, but where is the reply. It drives me nuts not to figure out how to implement a momentary push button.

    All web seraches have been unsuccessful.

    PLEASE

     

     

  • 14 years ago

    Hi,

    Can I know what do you mean by "output bit will be set high", if possible provide example.

     

    Hope I will be able to help you.

  • 14 years ago

    Ki Kassem:

    I'm writting a VB application for an automated system. I have the need to set an digital output "high" (ON) while the user presses a button. i.e.

    Button.Press Setout(on)

    Button.Released Setout(off)

    VB is event driven, therefore the standard button uses the CLICK event when pressed. This is one-shot deal.  I can not figure how to determine when the button is pressed and and when it is released.

    Thanks for trying to help me.

     

     

    Cycling is a lifestyle!

  • 14 years ago

    Hi,

    You shall catch the "Mouse Up" and "Mouse Down" events and add a timer in order to do that. To simulate your case I have added a vertical scroll bar and on click "Mouse Down" the value of the scroll bar will increase untill the button is released "Mouse Up". for testing this code just drop a command button, vertical scroll bar and a timer. Keep all the naming as it is and paste the below code in the code view.

    Private Sub Form_Load()

        Me.Timer1.Enabled = False
        Me.Timer1.Interval = 10

    End Sub

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

        If Me.Timer1.Enabled = False Then Me.Timer1.Enabled = True

    End Sub

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

        Me.Timer1.Enabled = False

    End Sub

    Private Sub Timer1_Timer()

    'Place your code for sending the signal here

        Me.VScroll1 = Me.VScroll1 + 100

    End Sub

     

    Hope this works for you.

  • 13 years ago

    It works great. Thank you very much.

     

    Cycling is a life style

Post a reply

Enter your message below

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

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.” - Rich Cook