Solved

clear button

Posted on 2008-10-05
4
164 Views
Last Modified: 2010-04-30
i want the clear button to clear the whole thing at one time. i got some code but i have to keep on hitting clear to clear each text box. help please. thank you.
Private Sub Clear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim Ctl As Control
        For Each Ctl In Me.Controls
            If TypeOf Ctl Is TextBox Then
                Ctl.Text = ""
            End If
        Next
    End Sub

Open in new window

0
Comment
Question by:elrayiss
  • 2
  • 2
4 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 22645738
which button do you have to keep on hitting? from what I see, hitting button2 should clear all the textbox but considering your other questions, you have code in the TextChanged event of some textbox that short-circuit the clearing.
0
 

Author Comment

by:elrayiss
ID: 22646264
what im doing is that when im hitting the clear button on one textbox at a time is clearing i want it to get cleared from one hit.
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 500 total points
ID: 22646401
set a class level variable to True before your loop, in all your textchanged event handler if the variable is true, set the textbox to empty otherwise do your process.
0
 

Author Closing Comment

by:elrayiss
ID: 31503223
excellent.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

805 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question