VB中如何实现键盘控制? 5
PrivateSubCommand2_Click(IndexAsInteger)DimmesflagAsIntegerIfNotDYFLAGThenShowFrmMsg(...
Private Sub Command2_Click(Index As Integer)
Dim mesflag As Integer
If Not DYFLAG Then
ShowFrmMsg ("xxx")
Exit Sub
End If
Select Case Index
Case 0
cmdflag = True
Case 1
cmdflag = False
End Select
If cmdflag = True And CEResuit = True Then
mesflag = 0
Else
mesflag = -1
End If SendMES strInspectSN & "," & mesflag
txtFTMES(0).Text = strInspectSN & "," & mesflag
DYFLAG = False
End Sub
本来是通过command鼠标点击来实现的,想通过按小键盘1和0键分别表示PASS和FAIL的测试结果。请问代码如何修改,请帮忙~!谢谢 展开
Dim mesflag As Integer
If Not DYFLAG Then
ShowFrmMsg ("xxx")
Exit Sub
End If
Select Case Index
Case 0
cmdflag = True
Case 1
cmdflag = False
End Select
If cmdflag = True And CEResuit = True Then
mesflag = 0
Else
mesflag = -1
End If SendMES strInspectSN & "," & mesflag
txtFTMES(0).Text = strInspectSN & "," & mesflag
DYFLAG = False
End Sub
本来是通过command鼠标点击来实现的,想通过按小键盘1和0键分别表示PASS和FAIL的测试结果。请问代码如何修改,请帮忙~!谢谢 展开
2个回答
展开全部
Private Sub Command2_Click(Index As Integer)
Dim mesflag As Integer
If Not DYFLAG Then
ShowFrmMsg ("xxx")
Exit Sub
End If
Select Case Index
Case 0
cmdflag = True
Case 1
cmdflag = False
End Select
If cmdflag = True And CEResuit = True Then
mesflag = 0
Else
mesflag = -1
End If
SendMES strInspectSN & "," & mesflag
txtFTMES(0).Text = strInspectSN & "," & mesflag
DYFLAG = False
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 49 Then Command2_Click 1
If KeyAscii = 48 Then Command2_Click 0
End Sub
Private Sub Form_Load()
Me.KeyPreview = True
End Sub
Dim mesflag As Integer
If Not DYFLAG Then
ShowFrmMsg ("xxx")
Exit Sub
End If
Select Case Index
Case 0
cmdflag = True
Case 1
cmdflag = False
End Select
If cmdflag = True And CEResuit = True Then
mesflag = 0
Else
mesflag = -1
End If
SendMES strInspectSN & "," & mesflag
txtFTMES(0).Text = strInspectSN & "," & mesflag
DYFLAG = False
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 49 Then Command2_Click 1
If KeyAscii = 48 Then Command2_Click 0
End Sub
Private Sub Form_Load()
Me.KeyPreview = True
End Sub
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = Asc("0") Then
Call Command2_Click(0)
ElseIf KeyAscii = Asc("1") Then
Call Command2_Click(1)
End If
End Sub
Private Sub Form_Load()
Me.KeyPreview = True
End Sub
If KeyAscii = Asc("0") Then
Call Command2_Click(0)
ElseIf KeyAscii = Asc("1") Then
Call Command2_Click(1)
End If
End Sub
Private Sub Form_Load()
Me.KeyPreview = True
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询