Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
文本框设置焦点VBA_Vba_Powerpoint_Setfocus - Fatal编程技术网

文本框设置焦点VBA

文本框设置焦点VBA,vba,powerpoint,setfocus,Vba,Powerpoint,Setfocus,我现在正在使用Powerpoint VBA,并尝试创建一个简单的登录系统 如果我的注意力集中在TextBox1上,我想在单击键盘上的TAB键时将焦点设置为TextBox2。 这是我的密码 Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _ ByVal Shift As Integer) If KeyCode = 9 Then TextBox2.SetFocus End If End Sub Private

我现在正在使用Powerpoint VBA,并尝试创建一个简单的登录系统 如果我的注意力集中在TextBox1上,我想在单击键盘上的TAB键时将焦点设置为TextBox2。 这是我的密码

Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)
If KeyCode = 9 Then
TextBox2.SetFocus
End If
End Sub

Private Sub TextBox2_Change()

End Sub

有什么问题吗?

你根本不应该这样做。只需为两个textbox控件正确设置
TabIndex
,然后按TextBox1中的Tab键将自动将焦点设置为TextBox2,代码为零。Ken是正确的。但您还需要确保文本框的TabKeyBehavior属性设置为FALSE。如果为FALSE,则tab键将在TabSTop属性为true的窗体上移动控件。如果为TRUE,则允许文本框像接受任何其他字符一样接受制表符。