Results 1 to 7 of 7

Thread: how to: press a command button by code

  1. #1

    Thread Starter
    New Member biifu's Avatar
    Join Date
    Feb 2001
    Location
    Italy
    Posts
    12

    Unhappy how to: press a command button by code

    something like:

    sub text1_keypress(keyascii as integer)
    if keyascii=48 then
    command0.press
    end if
    end sub
    Raffaella ti amo!

  2. #2
    Addicted Member Supester's Avatar
    Join Date
    Nov 2001
    Location
    The Netherlands
    Posts
    220
    command1_click

    Just call the procedure that handles the click event

  3. #3

    Thread Starter
    New Member biifu's Avatar
    Join Date
    Feb 2001
    Location
    Italy
    Posts
    12
    tnx, but i know it
    i need that le button is pressed while i'm writing on the keyboard, like the windows calculator does.


    i'm sorry 'bout my english
    Raffaella ti amo!

  4. #4
    New Member pari's Avatar
    Join Date
    Dec 2001
    Location
    on earth
    Posts
    13
    Hey!!!
    Use the Sendkeys method!!
    pari

  5. #5
    Hyperactive Member abhid's Avatar
    Join Date
    Nov 2001
    Location
    3rd rock from the sun
    Posts
    467
    can you make yourself more clear.
    windows calculator just does as suggested by supster. only difference is you cant make out the time difference bet click and display of character

  6. #6
    Junior Member
    Join Date
    Nov 2001
    Posts
    21
    Why dont you just disable it once and enable it again..simple man

  7. #7
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Well ...

    Originally posted by biifu
    something like:

    sub text1_keypress(keyascii as integer)
    if keyascii=48 then
    command0.press
    end if
    end sub
    I have a very crude solution.

    On a form, place a Checkbox, with its Style property set to 1-Graphical. Set the KeyPreview property of the form to True, and then paste the following code in the form's code window:

    VB Code:
    1. Private Sub Form_KeyPress(KeyAscii As Integer)
    2.     Dim I As Long, J As Long
    3.     If KeyAscii = Asc("1") Then
    4.         Check1.Value = 1
    5.         Me.Refresh
    6.         For I = 0 To 1000
    7.             For J = 0 To 1000
    8.             Next
    9.         Next
    10.         Check1.Value = 0
    11.         Me.Refresh
    12.     End If
    13. End Sub

    Run the project and when the form with the checkbox appears, press 1 to see the effect.

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

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