C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Statements: In the Click event handler, we can add some VB.NET code statements. Here, we access a field "x" on the Form1 class.
Enabled: We use the Enabled property on the Button. If the variable x is less than 10, the button remains enabled.
PropertyExample Click event handler: VB.NET
Public Class Form1
Dim x As Integer
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
' Increment local variable and change window title.
x += 1
Me.Text = x.ToString()
' If number is less than 10, it is still enabled.
' ... At 10, disable the button.
Button1.Enabled = x < 10
End Sub
End Class
But: When the variable x reaches 10, the button is disabled. Enabled is set to false.
Tip: Using expressions eliminates the need to use if-statements. Often, this simplifies programs and makes them easier to understand.
If Then