VB6如何检测发送的密钥将写入文本框
如何检测发送的密钥将写入文本框? 例如: 我将“W”发送到激活的程序VB6如何检测发送的密钥将写入文本框,vb6,key,send,Vb6,Key,Send,如何检测发送的密钥将写入文本框? 例如: 我将“W”发送到激活的程序 如何检测“W”被写入?这完全取决于如何将“W”发送到程序。。。。 如果您的意思是如果您实际键入,则可以使用文本框的事件 Private Sub Textbox_KeyPress(KeyAscii As Integer) If KeyAscii = Asc("W") then Call MsgBox("Yes 'W' pressed") End Sub Private Sub TextBox_KeyDown(KeyCode
如何检测“W”被写入?这完全取决于如何将“W”发送到程序。。。。 如果您的意思是如果您实际键入,则可以使用文本框的事件
Private Sub Textbox_KeyPress(KeyAscii As Integer)
If KeyAscii = Asc("W") then Call MsgBox("Yes 'W' pressed")
End Sub
Private Sub TextBox_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyW And ((Shift And vbShiftMask) = vbShiftMask) Then Call MsgBox("Yes 'W' pressed")
End Sub
或者,您需要使用\u Change事件跟踪更改,当然这需要做更多的工作,因为您需要存储以前的文本并将其与当前文本进行比较,然后查看是否添加了“W”。但你必须考虑到人们可能会粘贴多个字母
Private Sub TextBox_Change()
If Instr(TextBox.Text, "W")>0 Then
If Instr(TextBox.Tag, "W") = 0 Then
Call MsgBox("Yep 'W' added")
Else
'run down the Text along with the Tag and see if a 'W' is present at the same location
End If
End If
TextBox.Tag = TextBox.Text
End Sub
你想达到什么目标?