|
Subject:
|
Length of a Control Array
|
|
Posted By:
|
ackid32
|
Post Date:
|
9/19/2006 3:07:21 AM
|
Hi, How to find the length of control array. pls guide me.
Thanks
|
|
Reply By:
|
Rod Stephens
|
Reply Date:
|
9/19/2006 8:07:22 AM
|
VB .NET doesn't have control arrays so I presume you're using VB 6. There a control array has LBound and UBound properties that give its lower and upper bounds. For example, this code loops through the text box array named txtData:
For i = txtData.LBound To txtData.UBound txtData.Text = "" Next i If the array might be missing elements (i.e. you deleted one), see:
http://vb-helper.com/howto_safe_control_arrays.html
HTH,
Rod
Rod RodStephens@vb-helper.com Author of "Visual Basic 2005 Programmer's Reference" http://www.vb-helper.com/vb_prog_ref.htm
Sign up for the free VB Helper Newsletters at http://www.vb-helper.com/newsletter.html
|
|
Reply By:
|
ackid32
|
Reply Date:
|
9/19/2006 11:18:37 PM
|
Ha, im sorry, my actual code is
dim lbl as label
do while ctr < 10 lbl=new label lbl.setbounds(x...) me.addcontrols(lbl) loop ' i actually want to remove the 10 instances of the label. I try me.removecontrols, but i only remove it the added controls and not the instances.
so please
|
|
Reply By:
|
Rod Stephens
|
Reply Date:
|
9/22/2006 8:12:23 AM
|
How about:
For i As Integer = Me.Controls.Count - 1 To 0 Step -1 If TypeOf Me.Controls(i) Is Label Then Me.Controls.RemoveAt(i) End If Next
Rod
Rod RodStephens@vb-helper.com Author of "Visual Basic 2005 Programmer's Reference" http://www.vb-helper.com/vb_prog_ref.htm
Sign up for the free VB Helper Newsletters at http://www.vb-helper.com/newsletter.html
|