Solved

problem with Vbkey constants

Posted on 2003-11-01
5
621 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 

Author Comment

by:MaChao
ID: 9665473
plz someone help
0
 
LVL 17

Accepted Solution

by:
zzzzzooc earned 70 total points
ID: 9665584
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

710 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