Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

problem with Vbkey constants

Posted on 2003-11-01
5
Medium Priority
?
652 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 280 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

705 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