English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

請問各位前輩~~為何我使用複合鍵SHIFT+F7時KEYCODE卻抓到SHIFT的KEYCODE=16 ~~~但是SHIFT的值為1是正確的 ~~請問我要如何修改呢??
(以下是我的程式碼KEY_F7是常數=118,SHIFT_MASK=1)



Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim bolEditAllow As Integer
Dim intCheckParamOK As Integer
Dim i As Integer

If (KeyCode = KEY_F7) And (Shift And SHIFT_MASK) Then
If Not gIsCycleStart(Me) Then
If gSelectedDraftingData.DraftingNumber > 0 Then
For i = gNowKnifeJob To gSelectedDraftingData.DraftingNumber - 1
intCheckParamOK = fnCheckParam(gSelectedDraftingData.DraftingData(i).DraftingMode, gSelectedDraftingData.DraftingData(i).Drafting(), "砂輪", i + 1)
If Not intCheckParamOK Then
Exit Sub
End If
Next i
If gSaveDraftingToNC(Me, gNowKnifeJob) Then

Call gSaveO9801ToNC(Me, gNowKnifeJob)
' Call gSaveO9802ToNC(Me, gNowKnifeJob)
' Call gSaveO9803ToNC(Me, gNowKnifeJob)
' Call gSaveO9804ToNC(Me, gNowKnifeJob)
' Call gSaveO9805ToNC(Me, gNowKnifeJob)
' Call gSaveO9806ToNC(Me, gNowKnifeJob)
' Call gSaveO9807ToNC(Me, gNowKnifeJob)
' Call gSaveO9808ToNC(Me, gNowKnifeJob)
' Call gSaveO9809ToNC(Me, gNowKnifeJob)

MsgBox cProgSaveOK, MB_OK + MB_ICONINFORMATION + MB_APPLMODAL

2006-11-23 05:04:10 · 2 個解答 · 發問者 Anonymous in 電腦與網際網路 程式設計

不好意思~~小弟所用的版本是VB6.0~~請問有針對VB6.0的解決方式~~~謝謝^.^

2006-11-23 08:12:24 · update #1

2 個解答

'你有宣告KEY_F7跟SHIFT_MASK這2個常數嗎?Const KEY_F7 = 118Const SHIFT_MASK = 1If (KeyCode = KEY_F7) And (Shift And SHIFT_MASK) Then'還是乾脆直接改成:If KeyCode = vbKeyF7 And Shift = 1 Then

2006-11-24 07:28:48 · answer #1 · answered by W.J.S. 7 · 0 0

記得先將form的KeyPreview屬性設為true,然後參考以下程式碼
Private Sub Form1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If (e.Shift = True) Then
If (e.KeyCode = Keys.F7) Then
MsgBox("OK_Shift + F7")
Else
MsgBox("No_Shift")
End If
Else
MsgBox("No")
End If
End Sub

2006-11-23 06:21:13 · answer #2 · answered by ? 1 · 0 0

fedest.com, questions and answers