+ Reply to Thread
Results 1 to 6 of 6

shift click on form button

  1. #1
    Registered User
    Join Date
    12-23-2012
    Location
    Sofia, Bulgaria
    MS-Off Ver
    Excel 2007
    Posts
    4

    shift click on form button

    Hey there,
    I have a little experience with VBA and thus i need help, tx in advance if anyone can share some clues

    what i have is a form with buttons, clicking on them changes values in some form fields.
    i need the button when shift-clicked to change the value differently

    in my code i have

    Please Login or Register  to view this content.
    and then

    Please Login or Register  to view this content.
    and this works fine when shift-click is used, but it also behaves the same when the next click on the same button comes, even if it is not a shift click.

    any ideas how to make it work only the first time?

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: shift click on form button

    It seems to work for me. It adds one with just a click. It multiplies by 10 with Shift+Click. It then returns to adding 1 on regular click.

    Do you want it to Add 10 (not multiply) on a Shift+Click?
    Bilet1_count.Value = Bilet1_count.Value + 10

  3. #3
    Registered User
    Join Date
    12-23-2012
    Location
    Sofia, Bulgaria
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: shift click on form button

    well I don't know what is wrong, i have no idea.
    it performs correctly on the first time : multiplies by 10 on shift-click and just + 1 on click.
    but on my form the next regular click also multiplies by 10 as long as i click the same button.
    i have several buttons of the kind, the only difference is which field they alter.

    so, for example, if the value is 1, by shift-click it becomes 10, but then with simple click it becomes 100 instead of 11. next click makes it 101 tho...
    i'm lost :/

  4. #4
    Registered User
    Join Date
    12-23-2012
    Location
    Sofia, Bulgaria
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: shift click on form button

    anyway, it seems that the problem is related to if i release the shift in the same time with my mouse button or after, if i manage to do it simultaneously, the form behaves like expected, but if i release the shift key later, it behaves like if it is still pressed on the next mouse click. So the code is working, it just isn't fool-proof (proved by myself )

    tx for the attention tho
    Last edited by vedroks; 12-23-2012 at 12:57 PM.

  5. #5
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: shift click on form button

    Give this a try (based on MSDN GetKeyState function)...

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    12-23-2012
    Location
    Sofia, Bulgaria
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: shift click on form button

    tx, works like charm, now it works in spite of sticky fingers etc

    solved an annoying issue, cheers

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1