Solved

Textbox control

Posted on 1999-01-21
8
179 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
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 1

Accepted Solution

by:
amithvs earned 50 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 12

Expert Comment

by:mark2150
Comment Utility
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 1

Expert Comment

by:hddp666
Comment Utility
Yeah, Fortran, Cobol, &c.
0
 
LVL 12

Expert Comment

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

M

0
 
LVL 1

Expert Comment

by:hddp666
Comment Utility
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
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

762 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

7 Experts available now in Live!

Get 1:1 Help Now