-
Sep 25th, 2009, 06:00 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Reset Button for a textbox
Can anyone help me write a code for a Reset button to clear all information for a textbox.
-
Sep 25th, 2009, 06:11 PM
#2
Re: Reset Button for a textbox
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
textbox1.text = String.Empty
End Sub
where textbox1 is your textbox name, and button1 is the button name.
-
Sep 25th, 2009, 06:20 PM
#3
Thread Starter
Addicted Member
Re: Reset Button for a textbox
Thanks, and how could I make the words Reset Button appear in the textbox after I have pressed the reset button
-
Sep 25th, 2009, 06:28 PM
#4
Re: Reset Button for a textbox
you would replace string.empty in my example above with "Reset Button"
-
Sep 25th, 2009, 06:36 PM
#5
Thread Starter
Addicted Member
Re: Reset Button for a textbox
Last edited by noreaga_ls; Sep 25th, 2009 at 07:08 PM.
Reason: Started another topic
-
Nov 13th, 2017, 01:55 PM
#6
New Member
Re: Reset Button for a textbox
Originally Posted by noreaga_ls
Ok thanks
and if i want to reset multiple textbox?
-
Nov 13th, 2017, 03:55 PM
#7
Re: Reset Button for a textbox
Originally Posted by Theunkwon1
and if i want to reset multiple textbox?
So, think about it... If you had a control named Textbox1, and someone showed you how to change the .text property of textbox1, would you not suppose it should be a similar procedure for Textbox2, and os on?
If you're dealing with mass textboxs you can group them in panels or group box's and iterate them setting them accordingly. Here is an example of "resetting" all textboxs within a Group Box.
Code:
For Each Ctrl As Control In GroupBox_CorpInfo.Controls
If TypeOf Ctrl Is TextBox Then
Dim tbox As TextBox = CType(Ctrl, TextBox)
tbox.Text = "Reset Button"
End If
Next
This would be similar for any control that has a "Controls collection"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|