How to set the disabled state for a VB command button?

To disable a VB command button, you can use the button’s Enabled property. The button will become disabled when the Enabled property is set to False.

Below is an example code for setting a VB command button to a disabled state.

' 在Form_Load事件中设置按钮不可用状态
Private Sub Form_Load()
    Command1.Enabled = False
End Sub

' 在按钮的Click事件中设置按钮不可用状态
Private Sub Command1_Click()
    Command1.Enabled = False
End Sub

The statement Command1.Enabled = False in the code above sets the Enabled property of the button Command1 to False, making the button unavailable.

bannerAds