Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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:

Gary Says: To be a good programmer, you must be good at debugging
  • *Experts*
Posted

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

"Being grown up isn't half as fun as growing up

These are the best days of our lives"

-The Ataris, In This Diary

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...