-1
如何檢測發送的密鑰將寫入文本框? 例如: 我發送「W」給一個活動的程序 我怎麼能檢測到「W」被寫入?VB6如何檢測發送的密鑰將寫入文本框
如何檢測發送的密鑰將寫入文本框? 例如: 我發送「W」給一個活動的程序 我怎麼能檢測到「W」被寫入?VB6如何檢測發送的密鑰將寫入文本框
如果你的意思是,如果你真的鍵入這一切都取決於你如何發送「W」的程序.... ,您可以使用文本框的_KeyDown,_KeyUp或_KeyPress事件。 。
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
,或者您需要使用_Change事件,這ofcourse是你需要存儲以前的文本,並將其與當前的文本進行比較,看是否有更多的工作來追蹤變化'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
你想達到什麼目的? – cup