loyal Posted August 7, 2003 Posted August 7, 2003 hi all I have a 3 checkboxes and I want to arrange their location depend on their height but when I made a loop it gives me that the r not defined because my checkboxes named r1 , r2 , r3 how to solve this ? rolleyes: Dim i As Integer For i = 2 To 3 r(i).Location = New Point(r1.Location.X, r( i+1 ).Height + 30) Next: Quote Gary Says: To be a good programmer, you must be good at debugging
*Experts* Bucky Posted August 7, 2003 *Experts* Posted August 7, 2003 Control arrays are not supported in VB.NET in the way that you're used to them in VB6. You will need to create your own collection (probably an ArrayList), and add each checkbox to it, and then you can loop through that. You'll have to cast the checkboxes in the list by using DirectCast, unless you want to create your own strongly-typed version. ' In general declarations: Dim r As New ArrayList() ' In the form's Load event: With r .Add(r1) .Add(r2) .Add(r3) End With ' Then you can loop through the ArrayList r Dim i As Integer For i = 2 To 3 DirectCast(r(i), CheckBox).Location = New Point(r1.Location.X, DirectCast(r(i+1), CheckBox).Height + 30) Next Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.