作者waiter337 (給開司一罐蘇格登)
看板Office
標題[問題] vba表單 Keydown 遇到SetFocus
時間Fri Dec 9 01:57:50 2016
目前有個疑問
假設有兩個控件
textbox1
與
CommandButton1
當我用
Private Sub TextBox1_Keydown(ByVal KeyCode As MSForms.ReturnInteger, ByVal
Shift As Integer)
If KeyCode.Value = 13 And TextBox1.Text <> "" Then
textbox1.Setfocus
這種方式在textbox1上面輸入數字後 按下enter
光標卻一直跳去CommandButton1
懷疑是
1.按下enter 程式確實執行完成,光標跳至textbox1
2.當我放開enter ,結果照著excel預設值,就又跳去CommandButton1
我想要一直在textbox1 一直連續輸入
譬如 textbox1
a > enter > b > enter ........
都不會跳開textbox1
請問
除了關掉預設之外,
這個程式的邏輯該如何下
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.35.158.244
※ 文章網址: https://www.ptt.cc/bbs/Office/M.1481219872.A.25B.html
→ soyoso: 判斷內加上keycode=0 12/09 08:00
→ waiter337: 搞定 感謝! 12/09 19:13