shane098
Crypto Community Manager
2
MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1
400 XP
In this tutorial, I'm going to show how to create an application that will help you to save more time and number of lines of code just to clear your multiple textbox in a single form. This time, let's start building our application:
Step 1. Create a new project in visual Basic 2008, then design the interface that looks like as shown below:
Step 2. Double click the “Using "" ” button. Then add the following code:
Explanation:
The added code code in step 2, we simply set the text value of a text to an empty string.
Step 3. Double click the “Using Nothing” button and add the following code:
Explanation:
The new added code in step 3, we just set the text value of a textbox to Nothing.
Step 4. Double click the “Using Smart Clear” button and add the following code:
Explanation:
In the new added code in step 4, we use “For Each Next loop”. We set a variable “ctrl” as Control in “Controls” to get the collection of control contained within the control. Then we use the conditional logic, if statement to check if the Type of control is Textbox, then it will set the Text property of a textbox into “Nothing”.
Download
Step 1. Create a new project in visual Basic 2008, then design the interface that looks like as shown below:

Step 2. Double click the “Using "" ” button. Then add the following code:
- TextBox1.
Text
=
""
- TextBox2.
Text
=
""
- TextBox3.
Text
=
""
- TextBox4.
Text
=
""
- TextBox5.
Text
=
""
Explanation:
The added code code in step 2, we simply set the text value of a text to an empty string.
Step 3. Double click the “Using Nothing” button and add the following code:
- TextBox1.
Text
=
Nothing
- TextBox2.
Text
=
Nothing
- TextBox3.
Text
=
Nothing
- TextBox4.
Text
=
Nothing
- TextBox5.
Text
=
Nothing
Explanation:
The new added code in step 3, we just set the text value of a textbox to Nothing.
Step 4. Double click the “Using Smart Clear” button and add the following code:
- For
Each
ctrl As
Control In
Controls
- If
ctrl.
GetType
Is
GetType
(
TextBox)
Then
- ctrl.
Text
=
Nothing
- End
If
- Next
Explanation:
In the new added code in step 4, we use “For Each Next loop”. We set a variable “ctrl” as Control in “Controls” to get the collection of control contained within the control. Then we use the conditional logic, if statement to check if the Type of control is Textbox, then it will set the Text property of a textbox into “Nothing”.
Download
You must upgrade your account or reply in the thread to view the hidden content.