?
Solved

Textbox control

Posted on 1999-01-21
8
Medium Priority
?
211 Views
Last Modified: 2013-11-13
Suppose I have 10 textbox on a single form.I don't
want to write code like this:

  text1.text = ""
  text2.text = ""
    |
    |
  text10.text = "" 

  I don't want hard coding(like "text1" or "text2"
  or..."text10").And also i want to make it blank.

Please give me solution with less coding. may be in a single line ?

With warm regards,

Nilesh shah

0
Comment
Question by:Aurokripa
[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
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 1

Accepted Solution

by:
amithvs earned 150 total points
ID: 1469819
Try this....
Dim con As Control
For Each con In Form1
    If TypeOf con Is TextBox Then
    con.Text = ""
    End If
Next
0
 
LVL 1

Expert Comment

by:hddp666
ID: 1469820
You can also copy one textbox and paste over and over to create a control array, such as Text(1), Text(2), etc.

Dim i As Integer
For i = 0 to 9
   Text(i).Text = ""
Next i

0
 
LVL 2

Expert Comment

by:jrmcg
ID: 1469821
I would agree with hddp666, using the control array would also make operations easier down the line if the text box information is going to be related or similar.

J.R.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 12

Expert Comment

by:mark2150
ID: 1469822
Only change I'd make is that instead of coding "For i = 0 to 9" I'd code it "For i = Text1.Lbound TO Text1.Ubound" so it'll be dynamic as the control array size changes.

("For i ="??? Hmm, do I smell an old FORTRAN programmer out there? <G>)

M

0
 
LVL 1

Expert Comment

by:hddp666
ID: 1469823
Yeah, Fortran, Cobol, &c.
0
 
LVL 12

Expert Comment

by:mark2150
ID: 1469824
*thought so!* (grin) Old habits die hard, no?

M

0
 
LVL 1

Expert Comment

by:hddp666
ID: 1469825
Old habits don't die hard until after the faux-clever businessmen "save money" on engineers' and designers' salaries, right up to the brink of The Mother of All Crises, and then wind up paying dearly for the obsolete programming skills necessary to fix the "bargains" they obtained in the past 8-}

The Experts call this sort of behavior Penny-Wise and Krugerand-Foolish.

Ayn Rand called it Atlas Shrugged.
0
 
LVL 1

Expert Comment

by:amithvs
ID: 1469826
Maybe the user doesnt want to use control arrays as the text boxes may not be related.In that case the first option will only work
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

770 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