Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how would a real programmer handle a group of text boxes 1

Status
Not open for further replies.

seminewbee2005

Instructor
Jun 5, 2005
60
US
I have a group of textboxes that I dealt with using a control array. txtMach(0),txtMach(1) ans so on. I am new to vb.net and have read in my research vb.net does not support control arrays. SO how to do it?
thanks!!!

for example how to do something as simple as clearing a group of 5 text boxes in code?
 
I meant to say i dealt with them as a control array in vb6, how to deal with them in vb.net
 
My choices in how to do this would be, in order of decreasing performance:

1. Have 5 separate lines of code to clear them. Put this in it's own method for clarity's sake. Simplicity is a virtue.

2. Declare an array of 5 Textboxes, and assign the five to the array when the form loads. When you need to clear them, do a For Each..Next against the array

3. Do a For Each..Next against the Controls collection, and when the control equals one of your textboxes, clear it.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
waz wonderinf what that for each would look loike against the collection

say to clear all labels on a form?

for each ? I know how to do it in vb6 but not .net
 
from the VB.NET language spec:
msdn said:
ForEachStatement ::=
For Each LoopControlVariable In Expression StatementTerminator
[ Block ]
Next [Expression ] StatementTerminator
What this means is that you can do a For Each against any object that implements the System.Collections.IEnumerable interface, which most if not all collections and arrays do.
Code:
Dim c As ArrayList = New ArrayList()
Dim w as widget

' Add some widgets to c here

For Each w in c
   Console.WriteLine(w.ToString())
Next

Chip H.

____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top