Re: Newbie Advice/Critiscism




"Argusy" <argusy@xxxxxxxxxxxxxxx> wrote in message
news:467D25F3.7090605@xxxxxxxxxxxxxxxxxx
MikeD wrote:

That is indeed VB.NET code. Assuming you mean control arrays, there's no
such thing in .NET. Instead, you have procedures handle events for multiple
controls. For example, these two event procedures:
(snip)

could be "combined" into a single event procedure like this:

Private Sub Button_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click, Button2.Click

(snip)


Thanks, Mike.
God, no wonder I'm not interested in .dotnetting
That's a complete re-structure of "How To Do It" - definitely not VB classic
(But I LIKE arrays - it cuts programming code tremendously)

Graham


In fairness, you can make your own arrays of controls, something like

Dim Checks() As CheckBox = {CheckBox1, CheckBox2, CheckBox3}
Dim n As Integer
For n = 0 To 2
Checks(n).Checked = True
Next n

You can also add or remove event handlers that way:
Dim Buttons() As Button = {Button1, Button2}
Dim n As Integer
For n = 0 To 1
AddHandler Buttons(n).Click, AddressOf Button_Click
Next n

So it's not so bad ;-)


.