Functions of the TextChanged Event in Visual Basic .NET


1

There are several events where there are several UI (User Interface) or Toolbox components in Visual Studio, both using the VB.Net programming language and C# in creating desktop or website-based applications. These events have their respective functions based on the activity or command of a program against the Toolbox such as when inputting data, validating typing numbers or special letters in the TextBox, when double clicking on the Mouse against the User Interface such as TextBox, Button, and so on.

For this time we discuss the use of events TextChanged from the UI TextBox component that functions to execute, run programs, or validate data when typing or changing numbers, letters, or symbols on an ongoing basis using VB.Net programming. You can make a program or statement in the TextChanged event according to your needs such as searching for data, calculating a number, matching words or data and so on.

For versions of Visual Studio that support events TextChanged this starts from Visual Studio 2003, Visual Studio 2005, Visual Studio 2008, Visual Studio 2010, and so on until the latest version of Visual Studio.

So, every time you type a letter, number, or symbol it is very influential in event activities TextChanged from the UI TextBox component so you have to be careful in providing coding or statements in the event environment TextChanged which are mainly things that deal with calculations or Mathematics, retrieval of data from databases both SQL and NoSQL in desktop applications.

Writing Form:

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

‘You can make a program or statement here

End Sub

Example Source Code:

Example 1:

This sample source code is to calculate the product of the two numbers.

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

TextBox3.Text = Val(TextBox1.Text) * Val(TextBox2.Text)

End Sub

Example 2:

Example source code to determine whether the number of characters in TextBox1 is 8 characters(?).

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

If TextBox1.Length = 8 Then

TextBox2.Focus

End If

End Sub

CLOSING

Events TextChanged on the UI TextBox component or the type of text input that supports this event can be your choice to create a program that plays a role in data validation in data searches, matching data or words, calculating a number or things related to Mathematics without having to click the button again in desktop or web-based applications using the Visual Basic .NET programming language.

This can shorten work activities in creating desktop-based applications or ASP websites using the Visual Basic.NET programming language that uses Events. TextChanged as an alternative in the event when the button is clicked to validate data or run a certain program.

Leave a comment

Your email address will not be published.