Tip When the button is clicked, the Button1_Click event handler is executed. The title of the Window is changed to equal the click count.
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
Expressions. This program shows how to use expressions to control interface elements. The Enabled property is assigned True or False based on an expression.
And It is true when the variable "x" is less than 10. So the button remains enabled.
But When the "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.