Connecting Tech Pros Worldwide Forums | Help | Site Map

Control Arrays

Brian Shafer
Guest
 
Posts: n/a
#1: Feb 20 '06
Hi,
I loved being about to use control arrays in vb classic. Doesn't look like
i can do this in vb.net?
Any input?



R. MacDonald
Guest
 
Posts: n/a
#2: Feb 20 '06

re: Control Arrays


Hello, Brian,

I also thought that I would miss this feature. I was wrong!

In .Net you can use arrays or collections of controls. I think that
once you get into it you will find this is more versatile than the old
VB "control arrays".

One reason that I used to like the old VB control arrays was the ability
it gave to use the same event handler for a number of controls. In .Net
you can not only assign the same event handler to multiple controls, but
(unlike with the old VB control arrays) the controls can be of diverse
types. So for example, you can have the same handler deal with text
changes in a TextBox or a ComboBox.

Cheers,
Randy


Brian Shafer wrote:
[color=blue]
> Hi,
> I loved being about to use control arrays in vb classic. Doesn't look like
> i can do this in vb.net?
> Any input?
>
>[/color]
Peter Huang [MSFT]
Guest
 
Posts: n/a
#3: Feb 20 '06

re: Control Arrays


Hi Brian,

VB.NET and VB has the similar VB syntax, but the VB.NET is new designed
..NET programming language based on CLR.
The control array is no longer supported in VB.NET.
Here is link for your reference.

Control Array Changes in Visual Basic .NET
http://msdn.microsoft.com/library/de...us/vbcon/html/
vbconcontrolarraychangesinvisualbasicnet.asp


Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Herfried K. Wagner [MVP]
Guest
 
Posts: n/a
#4: Feb 20 '06

re: Control Arrays


"Brian Shafer" <bsgallatin@community.nospam> schrieb:[color=blue]
> I loved being about to use control arrays in vb classic. Doesn't look
> like i can do this in vb.net?[/color]

Accessing controls by their names or indices
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=controlbynameindex&lang=en>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Cor Ligthert [MVP]
Guest
 
Posts: n/a
#5: Feb 20 '06

re: Control Arrays


Peter,
[color=blue]
> Control Array Changes in Visual Basic .NET
> http://msdn.microsoft.com/library/de...us/vbcon/html/
> vbconcontrolarraychangesinvisualbasicnet.asp
>[/color]
Can that page not be removed or be corrected? It is not giving the right
information.
(there is so old that there is not even a link on that to report that).

See the answer from Randy. I would have written something the same as he
had not done that.

Cor


CMM
Guest
 
Posts: n/a
#6: Feb 20 '06

re: Control Arrays



Private myButtons As Button() = {Button1, Button2}

Private Sub Form_Load(...)
For Each btn As Button In myButtons
AddHandler btn.Click, AddressOf myButtons_Click
Next btn
End Sub

or

Private Sub myButtons_Click(...) Handles Button1.Click, Button2.Click
....
End Sub

--
-C. Moya
www.cmoya.com


Closed Thread


Similar Visual Basic .NET bytes