Solved

clear button

Posted on 2008-10-05
4
163 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 69

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 69

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
mapAB Challlenge 35 126
Change the path of the data source in my Excel pivot table with macro 4 34
recursion example 16 111
Python 3.5.2 32 virtualenv problems 3 11
There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now