473,387 Members | 3,033 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Clear a number of textboxes in one time

Hello,

I have a few textboxes placed on a SSTab control devided over 3 tabs
Is there a way to clear all textboxes in one time in stead of one by one.

Someone told me "Use for each item in.........."
???????????
T.i.a.

regards,

Tino Wintershoven
The Netherlands

p.s.
Merry X-mas
Jul 17 '05 #1
4 11395
"T. Wintershoven" <pl*********@grp.com> wrote
Hello,

I have a few textboxes placed on a SSTab control devided over 3 tabs
Is there a way to clear all textboxes in one time in stead of one by one.

Someone told me "Use for each item in.........."
???????????

There is no one command to clear all textboxes. You have to do them
individually. Are your textboxes part of an array? If so, use For/Each
on that array. If not, use For/Each on the Controls collection and text
each item to be sure it is a textbox.

If you are doing that sort of thing in several different places, with
sometimes different textboxes, then it may pay to turn it into a command:

Private Sub ClearText(ParamArray Boxes())
Dim box
For Each box In Boxes
box.Text = ""
Next
End Sub

You can use that like:

ClearText Text1, Text3, Text11, Text15
ClearText Text2, Text4

It will accept any number of controls, just be sure they are Textboxes....

HTH
LFS


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 17 '05 #2
Here is the code ...

-Adheer Pai.

' Form/Module declaration
Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long

Private Sub cmdClearSSTabTextBoxes_Click()
Dim controlOnForm As Control
For Each controlOnForm In Me.Controls 'For each control on this form
'If the Control is a "TextBox" and its parent hWnd = SSTab hWnd set its
Text = ""
If (TypeName(controlOnForm) = "TextBox") And (SSTab1.hwnd =
GetParent(controlOnForm.hwnd)) Then
controlOnForm.Text = ""
End If
Next
End Sub

"T. Wintershoven" <pl*********@grp.com> wrote in message
news:1071616160.292384@cache1...
Hello,

I have a few textboxes placed on a SSTab control devided over 3 tabs
Is there a way to clear all textboxes in one time in stead of one by one.

Someone told me "Use for each item in.........."
???????????
T.i.a.

regards,

Tino Wintershoven
The Netherlands

p.s.
Merry X-mas

Jul 17 '05 #3
> Here is the code ...

-Adheer Pai.

' Form/Module declaration
Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Private Sub cmdClearSSTabTextBoxes_Click()
Dim controlOnForm As Control
For Each controlOnForm In Me.Controls 'For each control on this form
'If the Control is a "TextBox" and its parent hWnd = SSTab hWnd set its Text = ""
If (TypeName(controlOnForm) = "TextBox") And (SSTab1.hwnd =
GetParent(controlOnForm.hwnd)) Then
controlOnForm.Text = ""
End If
Next
End Sub


I would avoid the API call and do it this way instead...

Dim controlOnForm As Control
For Each controlOnForm In Me.Controls
If TypeOf controlOnForm Is TextBox Then
If controlOnForm.Container Is SSTab1 Then
controlOnForm.Text = ""
End If
End If
Next

Note that both your code and mine will not clear any TextBoxes embedded in
another container even if that container is located on the SSTab control.

Rick - MVP
Jul 17 '05 #4
Thanks all for your reaction.

Tino

"T. Wintershoven" <pl*********@grp.com> wrote in message
news:1071616160.292384@cache1...
Hello,

I have a few textboxes placed on a SSTab control devided over 3 tabs
Is there a way to clear all textboxes in one time in stead of one by one.

Someone told me "Use for each item in.........."
???????????
T.i.a.

regards,

Tino Wintershoven
The Netherlands

p.s.
Merry X-mas

Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: ian.davies52 | last post by:
Is there anything I can do about the apparent limit on the number of textboxes that have calculations as their control source on a form or report in ms-access? I have a query that pulls together...
5
by: nx-2000 | last post by:
I've got a very large C# forms app and now that its being used in bigger environments we're getting a steady stream of "why does it do this?" problems. The most nagging of which right now is that...
0
by: TN Bella | last post by:
Hi, Here is part of one sub where I want to clear all textboxes (there are three subs where I do this, one contains more textboxes, the other is below and the final one looks the same but omits...
1
by: Chris | last post by:
Hi, I have a page with quite a few textboxes and dropdownlist controls. How can I clear the textboxes and reset the dropdownlist after the data is sent to the database? Do I have to perform ...
13
by: KKuser | last post by:
Hello: I have 20, 30 text and combo boxes on one form, and I would like to clear them up at one time using the statement "With..........End With". I used this when using VB6, but I don't know...
19
by: Krishanu Debnath | last post by:
Hello, I have a call to hash_map::clear() function which takes long time. someClass::someFunction() { // typedef hash_map<name_id, uintMp; // Mp p; // assuming proper namespace, hash...
3
by: saikrishna | last post by:
Pls let me know is there any control to clear all textboxes at a time in C# Thanks and regards Sau
6
by: RP | last post by:
I want to clear all the Text Boxes on the Form. Is there any short method to avoid clearing them one by one.
1
by: adarshyam | last post by:
can anybody tel me how to clear values from dynamically created text boxes?? using a clear button.. this is the code used to create dynamic text boxes.. if i press clear button then it must clear all...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.