Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Textbox control

Posted on 1999-01-21
8
Medium Priority
?
219 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Monitor input from a computer is usually nothing special.  In this instance it prevented anyone from using the computer.  This was a preconfiguration that didn't work.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

618 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