TabStop 属性示例TabStop property example

以下示例使用**TabStop** 属性控制用户是否可以按 tab 将焦点移到特定控件。The following example uses the TabStop property to control whether a user can press Tab to move the focus to a particular control. 用户按 Tab 在窗体上的控件之间移动焦点, 然后单击**切换按钮** 以更改 CommandButton1 的TabStopThe user presses Tab to move the focus among the controls on the form, and then clicks the ToggleButton to change TabStop for CommandButton1. TabStopFalse时, CommandButton1 将不会使用 Tab 接收焦点。When TabStop is False, CommandButton1 will not receive the focus by using Tab.

若要使用此示例,请将此示例代码复制到窗体的 Declarations 部分。To use this example, copy this sample code to the Declarations portion of a form. 确保该窗体包含:Make sure that the form contains:

Private Sub CommandButton1_Click() 
 MsgBox "Clicked CommandButton1." 
End Sub 
Private Sub ToggleButton1_Click() 
 If ToggleButton1 = True Then 
 CommandButton1.TabStop = True 
 ToggleButton1.Caption = "TabStop On" 
 CommandButton1.TabStop = False 
 ToggleButton1.Caption = "TabStop Off" 
 End If 
End Sub 
Private Sub UserForm_Initialize() 
 CommandButton1.Caption = "Show Message" 
 ToggleButton1.Caption = "TabStop On" 
 ToggleButton1.Value = True 
 ToggleButton1.Width = 90 
End Sub

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.