CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2001
    Posts
    65

    How can I make a button click twice...

    Hi,
    I have a button, but for what I want it to do, I need to click it twice to reset the situation in my game.

    The code at the moment is :

    Man1.Picture = Man2.Picture
    Timer3.Enabled = Not Timer3.Enabled

    Then Timer3 is :

    Time2.Enabled = False

    Instead of clicking this button TWICE, Is there a way to make the buton click twice when you click it once (i.e. a command, or something).


  2. #2
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: How can I make a button click twice...


    private sub command1_click()
    static intX as integer
    'your normal code
    intX = intX +1
    if intX < 2 then
    call command1_click()
    'before executing next line of code, it will do the second call
    'to itself
    intX = 0
    end if
    end sub




    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  3. #3
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: However...

    You'd better write your code to avoid "double clicking" of a command button:
    you can put your code in a sub, and call it twice from command button click:

    private Mysub()
    'your code
    End Sub
    private sub command1_click()
    'do it twice:
    call Mysub
    call Mysub
    End Sub




    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured