Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shortcut key does not act like Mouse Click

Status
Not open for further replies.

rjmccorkle

Programmer
Aug 26, 2000
55
US
I'm using VB6. In some of the code I wrote, the shortcut key for a command control does not cause all of the code in the Click_event to be executed; some does and some doesn't. If I throw in a msgbox the all code executes. If I step thru the code in debug mode it all executes. Clicking with the mouse works OK. I've noticed that it doesn't execute the Lost_Focus events when shortcut keys are used also.

Here is the code. The <<lblID.caption=&quot;-1&quot;>> is what I noticed the shortcut key won't execute but the mouse click does:

Private Sub cmdChAdd_Click()
Dim vF As Integer
vgResult = MsgBox(&quot;Add New Client?&quot;, vbOKCancel)
If vgResult <> vbOK Then Exit Sub
'use Tag to go back to current Child in case of cancel
lblID.Tag = lblID.Caption
cboChName.Text = &quot;&quot;
cboSSN.ListIndex = -1
For vF = 0 To txtChild.Count - 1
txtChild(vF).Text = &quot;&quot;
Next vF
chkRespite.Value = 0
For vF = 0 To cboChild.Count - 1
cboChild(vF).ListIndex = -1
cboChild(vF).Tag = -1
Next vF
txtChild(0).SetFocus
'use Tag to go back to current Child in case of cancel
If lblID.Caption > &quot;0&quot; Then
lblID.Tag = lblID.Caption
Else
lblID.Tag = 0
End If
'set CID to -1 to indicate adding new
lblID.Caption = &quot;-1&quot;
Call SetState(&quot;ChildEdit&quot;)
lblEdit.Caption = &quot;Adding NEW&quot;
lblEdit.Tag = &quot;NEW&quot;
'set focus back to where it was right before clicking Edit
If vEditFocus > 99 Then
cboChild(vEditFocus - 100).SetFocus
Else
txtChild(vEditFocus).SetFocus
End If
End Sub

I tried a simple project of a command button with shortcut key and a label and have the command click_event change the label caption. It works with the shortcut or the mouse.
Thanks for any help.
Bob
104122.315@compuserve.com [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top