Solved

problem with Vbkey constants

Posted on 2003-11-01
5
587 Views
Last Modified: 2007-11-27
Im having a problem with vbkeyconstants

the first is that if i make vbkeyreturn,vbspace,vbkeyseparator have some shortcuts for certain buttons the return displays the answer of the button which is selected with tabindex.

the second is that my vbnumpad shortcuts only work if a button with a integer is selected(slighty highlighted) with the tabindex.

i dunno whether it is a glitch or something if my code: (oh the ones it works on are in an array)

ill post some of the code

Private Sub Digits_Click(Index As Integer) 'digits with numbers, virtual numpad
If Cleardisplay Then
display.Caption = ""
Cleardisplay = False    'clears display
End If
display.Caption = display.Caption + Digits(Index).Caption 'puts value on command.caption into display.caption
If display.Caption = "00" Then display.Caption = 0
 End Sub

Private Sub Digits_Keydown(Index As Integer, KeyCode As Integer, Shift As Integer)
Select Case KeyCode 'keyboard shortcuts
Case vbKey1, vbKeyNumpad1
     Call Digits_Click(1)
Case vbKey2, vbKeyNumpad2
    Call Digits_Click(2)
Case vbKey3, vbKeyNumpad3
    Call Digits_Click(3)
Case vbKey4, vbKeyNumpad4
    Call Digits_Click(4)
Case vbKey5, vbKeyNumpad5
    Call Digits_Click(5)
Case vbKey6, vbKeyNumpad6
    Call Digits_Click(6)
Case vbKey7, vbKeyNumpad7
    Call Digits_Click(7)
Case vbKey8, vbKeyNumpad8
    Call Digits_Click(8)
Case vbKey9, vbKeyNumpad9
    Call Digits_Click(9)
Case vbKey0, vbKeyNumpad0
    Call Digits_Click(0)
Case vbKeyMultiply
    Call times_Click
Case vbKeyAdd
    Call plus_Click
Case vbKeyDivide
    Call divide_Click
Case vbKeySubtract
    Call minus_Click
Case vbKeyDecimal
    Call Dobbtn_Click
Case vbKeyDelete
    Call Clearbttn_Click
Case vbKeyBack
    Call backspace_Click
End Select
End Sub


plz help.

MaChao
0
Comment
Question by:MaChao
5 Comments
 

Author Comment

by:MaChao
Comment Utility
plz someone help
0
 
LVL 17

Accepted Solution

by:
zzzzzooc earned 70 total points
Comment Utility
I take it that the control Digits is a label? If so, for it to receive the Keydown event it will have to have focus. If not, the current label (Digits) that has focus will fire the event. It would be best to use the KeyPreview property (true) and trap the Keydown events at form-level. I'm really a bit confused so I may have you wrong.



Form1:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    Select Case KeyCode
        Case vbKeyNumpad0
            MsgBox "Numpad0"
        Case vbKeyNumpad1
            MsgBox "vbKeyNumpad1"
        Case vbKeyReturn
            MsgBox "vbKeyReturn"
    End Select
End Sub
Private Sub Form_Load()
    Me.KeyPreview = True
End Sub
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now