index

  • Thread starter Thread starter Maarten
  • Start date Start date
M

Maarten

hi all

i've just instaled visual studio.net
im used working with vb 6.0

when i coppy a control in 6.0 he askes if i want to create an array.

in .net it isn't he just creates for exmple checkbox1, checkbox2; checkbox3;
....

and in the property window i can't create an index. (the option isn't there)

is this some magor change in .net or am i asking something realy stupid here
..

plz help me

kind regards Maarten
 
Maarten,

This is the suprise of those who comes from VB6 that this is not standard
anymore in VBNet.

However in VBNet you can make a lot of arrays with all kind of controls.

Cor
 
this indeed was a suprise i'm using indexes lots of times in my program, but
i just don't know how to create them.

can you gif me an example of creating an array with 16 checkboxes?

thank you verry much

Maarten
 
Maarten said:
this indeed was a suprise i'm using indexes lots of times in my program, but
i just don't know how to create them.

can you gif me an example of creating an array with 16 checkboxes?

One advantage to using a control array was that you could refer to all the
controls using one name, and an index value. Not so anymore. Every
control you use gets its own name. You can, however, build an array
that holds all of the individual controls:

Dim MyControls As CheckBox() = New CheckBox(){ CheckBox1, CheckBox2, _
CheckBox 3, CheckBox4, _
...
CheckBox13, CheckBox14, _
CheckBox15}


Also, they all have their own events, but you can declare a single routine to
handle events from all the controls:

Private Sub CheckBox_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles CheckBox1.Click, CheckBox2.Click, CheckBox3.Click, ( etc...)


You can even declare routines to handle events from entirely different types of
controls, just by adding them to that Handles list....

LFS
 
Larry,

Maarten does not know how it works on VB6, he told he knows it VBNet.

A curious situation, however maybe you can in this special case help him
with that because it shows than in this newsgroup nice the difference.
Because you have now showed nice the VBNet way.

:-)

Cor
 
Cor Ligthert said:
Maarten does not know how it works on VB6,

Did you see this:

Maarten:
"i've just instaled visual studio.net
im used working with vb 6.0"

That indicates he _is_ familiar with VB6....
LFS
 
Larry,

You are right, and would probably have given almost the same answer as you
directly when I had readed it as it is written. I readed it completly
different and was completly suprissed that somebody did first use VBNet and
than VB6.

Stuppid me.

Cor

"Larry Serflaten"
 
thanks for the reply's

it's not easy getting my way out of these changes.
i've taken a look at he site you gave me and made a contral array pannel.
it works fine, but i still have to make relative long codes to do what i
want.

for example

i'm using a PLC as domotica system for my house.

if i want so set an output of the card i just want to click a checkbox.
(there are 16)

so i have to work with select case , this means i have to write
select case ...

case 1
settiochannel1
case 2
settiochannel2
case 3
settiochannel3
....

while i normaly just did

for inti is 1 to 16
if check1(inti) = vb checked then
setiochannel(inti)
next inti

this is a propper way i think, but there must be some advantages of using
..net
but i'm still not there.

i hope someone can help me out, to make a simullar code as the last one

kind regards Maarten
 
Maarten said:
thanks for the reply's

it's not easy getting my way out of these changes.
i've taken a look at he site you gave me and made a contral array pannel.
it works fine, but i still have to make relative long codes to do what i
want.

Perhaps you didn't understand that you can put all of your checkboxes
in an array? Maybe example code will help:

LFS

Private Checks As CheckBox()

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Checks = New CheckBox() {CheckBox1, CheckBox2, CheckBox3, CheckBox4}
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
For idx As Integer = 0 To Checks.GetUpperBound(0)
If Checks(idx).Checked Then
' SetIoChannel(Idx)
Debug.WriteLine(idx)
End If
Next
End Sub
 
thank you verry much

that's what i want to know

kind regerds Maarten

Larry Serflaten said:
Perhaps you didn't understand that you can put all of your checkboxes
in an array? Maybe example code will help:

LFS

Private Checks As CheckBox()

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Checks = New CheckBox() {CheckBox1, CheckBox2, CheckBox3, CheckBox4}
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
 
I understand that at runtime I can emulate to control arrays!

But They were a very significant Design-time concept in VB6...
That's the big issue from my viewpoint.
 
Greg,

Yes however in my opinion were they a mix between a Ms-Access way of
creating programs and using a programming lanuage (somewhere hidden not
changable actions).

I have understand that in VB2005 a lot of Ms-Access kind of tools will
return, you understand it, I regret that. (However maybe it is than the
point that a lot of VBNet programmers go to C# and leave VB forever)

Just my thought

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top