Solved

clear button

Posted on 2008-10-05
4
174 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
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…

729 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