Solved

problem with Vbkey constants

Posted on 2003-11-01
5
613 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
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

828 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