2014-08-30 69 views
0

請原諒我,如果這是不可能的,這裏的情況。make program按回車鍵上的文本框重點

我有2個文本框,我在textbox1上鍵入一些內容並按下回車鍵,文本進入文本框2,程序按下文本框2上的回車鍵(用戶不會按回車鍵)。

下面是我在textbox1_keydown

if e.keycode = keys.enter then 
    str = textbox1.text 
    textbox2.focus() 
    textbox2.text = str 
    'Make textbox2 press the enter key here, without user pressing it on keyboard 
end if 
+0

第二進入新聞界去在TextBox2中的下一行? – 2014-08-30 01:53:41

+0

這是一個Windows窗體程序嗎? – 2014-08-30 02:10:52

+0

@JohnSaunders是的。 – sabre 2014-08-30 02:12:33

回答

1

找到了答案

if e.keycode = keys.enter then 
    str = textbox1.text 
    textbox2.focus() 
    textbox2.text = str 
    'Make textbox2 press the enter key here, without user pressing it on keyboard 
    SendKeys.Send("{ENTER}") 
end if 
0
If e.keycode = Keys.Enter Then 
      '/* Check whether textbox1 is empty or not */ 
     If textbox1.text <> "" Then 
      textbox2.text = "" 
      textbox2.text = textbox1.text 
      SendKeys.Send("{ENTER}") 
     Else 
     '/* if textbox1 is empty then cursor focus on textbox1 only */ 
      textbox1.focus() 
     End If 
    End If 

OR

If e.keycode = Keys.Enter Then 
     textbox2.text = "" 
     textbox2.text = textbox1.text 
     SendKeys.Send("{ENTER}") 
    End If