Button Control | VB.Net

Windows Forms controls are invaluable, reusable components that encapsulate various aspects of user interface functionality, catering to client-side Windows applications. Among these controls, Buttons stand out as essential interactive components that facilitate user interaction within an application.

Clickable Element

A Button control represents a visually distinct and clickable element, allowing users to initiate communication with the application. By clicking and subsequently releasing the Button, users can trigger specific actions or functions within the program. This interactive behavior serves as a crucial mechanism for engaging with the application's features and functionality.

vb.net-button.jpg

The Button control represents a standard button that reacts to a Click event. A Button can be clicked by using the mouse, ENTER key, or SPACEBAR if the button has focus.

When you want to change display text of the Button , you can change the Text property of the button.

Button1.Text = "My first Button"

Similarly if you want to load an Image to a Button control , you can code like this.

Button1.Image = Image.FromFile("C:\testimage.jpg")

The following vb.net source code shows how to change the button Text property while Form loading event and to display a message box when pressing a Button Control.

Full Source VB.NET
Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Button1.Text = "Click Here" End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click MsgBox("https://net-informations.com/vb/default.htm") End Sub End Class

Conclusion

Buttons, as part of the Windows Forms controls, play a vital role in enhancing the user experience and enabling seamless communication between the user and the application. Their intuitive nature and versatility make them a cornerstone of user interface design, enabling developers to create dynamic and interactive Windows applications.