Check Box Control Array?

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

I am just beginning with VB and had been using a crippled
version of VB 6.0 which works fine except there's limited
information resouces with it. So, like a good scout, I
got a learning edition of VB.Net, 2002, which has far
better resources. But there are changes which I don't
understand.

No problem creating a Check Box Control Array in VB 6.0
but that whole thing has changed in the upgrade to
VB.Net. How would I do this? Keep it simple please. I
assume I will need to write some code...not a clue about
that. Help would be most appreciated. Thank you.
 
Hi Mike,

Giving simple answers needs examples of your problems.

Now it looks if you ask to give you all we know about a Check Box Control
Array because you said that the whole thing has changed and because it looks
for you complex, we have to do that in a simple way. .

So maybe if you give more details from your problems, that we then can help
you.

I asume that you are not upgrading it from VB6 but are making it new.
Otherwise you can ask this in the special newsgroup for VB.net language
upgrade too.

Cor
 
Mike said:
I am just beginning with VB and had been using a crippled
version of VB 6.0 which works fine except there's limited
information resouces with it. So, like a good scout, I
got a learning edition of VB.Net, 2002, which has far
better resources. But there are changes which I don't
understand.

No problem creating a Check Box Control Array in VB 6.0
but that whole thing has changed in the upgrade to
VB.Net. How would I do this? Keep it simple please. I
assume I will need to write some code...not a clue about
that. Help would be most appreciated. Thank you.

There are no classic control arrays anymore because due to some enhancements
in the language, they are not required anymore. You can add the check boxes
to an array, for example this way:

dim MyCheckboxes As CheckBox()

MyCheckboxes = New CheckBox(){chk1, chk2, chk3}
 
hi mike,
i dont know if i get you right.... you're referring to check box control
array which in vb6 you do it by having

mycheckbox(0)
mycheckbox(1)
 
They don't exist but it's easy to create an arraylist that holds everything
like the other posters indicated. You can also use EventHandlers and wire
them to multiple events so the same code fires for all of your controls.
 
Hello,

Mike said:
I am just beginning with VB and had been using a crippled
version of VB 6.0 which works fine except there's limited
information resouces with it. So, like a good scout, I
got a learning edition of VB.Net, 2002, which has far
better resources. But there are changes which I don't
understand.

No problem creating a Check Box Control Array in VB 6.0
but that whole thing has changed in the upgrade to
VB.Net. How would I do this? Keep it simple please. I
assume I will need to write some code...not a clue about
that. Help would be most appreciated. Thank you.

Creating Control Arrays in Visual Basic .NET and Visual C# .NET
http://msdn.microsoft.com/library/?...ngControlArraysInVisualBasicNETVisualCNET.asp
 
The simplest thing to do is to go ahead and create all the checkboxes you
need, giving them different names.

Double click on one of them and then look at the Sub declaration line that
is created for you. Scroll to the end of the line and you'll see something
like:

Handles Checkbox1.click

Add a comma and the additional checkboxes and events to this list:


Handles Checkbox1.click, Checkbox2.click, Checkbox3.click, etc.

Now, no matter which checkbox gets clicked, this one sub routine will fire
(this was one of the benefits of the old control array).

You'll now be faced with a problem. How to determine which control got
clicked and caused the event to fire? That's what the "sender" event
argument is for. It represents the object that fired the event in the first
place.

You could figure out which checkbox fired the event several ways, but here
is a simple way:

Select Case Sender.name
Case Checkbox1

Case Checkbox2

Case Checkbox3

etc.

End Select

Good luck!
 
Back
Top