473,396 Members | 1,966 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Loop Control array

Hello,
Could you explain me,In VB6 using control array,and how
about VB.net.

Thanks
Nov 20 '05 #1
20 2352
Hi Samean,

A lot of methods, so tell what you want to archieve because a general one
does probably not help you.

Cor
Nov 20 '05 #2
Hi,

http://www.windowsforms.com/default....mID=16&mid=142

http://msdn.microsoft.com/library/de...et05132003.asp

Ken
---------------------------
"samean" <an*******@discussions.microsoft.com> wrote in message
news:70****************************@phx.gbl...
Hello,
Could you explain me,In VB6 using control array,and how
about VB.net.

Thanks
Nov 20 '05 #3

"samean" <an*******@discussions.microsoft.com> wrote in message
news:70****************************@phx.gbl...
Could you explain me,In VB6 using control array,and how
about VB.net.


For VB6, ask in microsoft.public.vb.general.discussion, and for .NET, they
no longer exist.
Nov 20 '05 #4
>and for .NET, they no longer exist.

Are you sure of that, I though exactly the oposite.

Cor
Nov 20 '05 #5

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:Os*************@TK2MSFTNGP12.phx.gbl...
and for .NET, they no longer exist.


Are you sure of that, I though exactly the oposite.


Control arrays no longer exist in .NET, I know that for sure. However, I may
have slightly misinterpreted the poster's question. I read "How do you loop
through a control array in VB6 and .NET?" The question may actually have
been, "How do I loop through controls? Please show me using a control array
in VB6 and however it's done in .NET."
Nov 20 '05 #6
Hi Jeff,

All controls exist as arrays now (or reference in a control.collections
however that is for me the same, it is uses Ilist).

That means that there are as I wrote more possibilities, I give here 3
however it is of course endless.

One which looks I thought the most as the one that was in VB6.
\\\needs two buttons and a label on a form
Dim btnArea As Button() = New Button() {Button1, Button2}
For Each btn As Button In btnArea
AddHandler btn.MouseLeave, AddressOf Button_MouseLeave
Next
Private Sub Button_MouseEnter(ByVal sender As Object, _
ByVal e As System.EventArgs)
Me.Label1.Text = DirectCast(sender, Button).Name
End Sub
///
The most standard one
\\\
For each btn as button in me.controls
if typeof btn Is Button then
bla bla bla
end if
next
///
And the one I like the most.
\\\
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
doset(Me)
End Sub
Private Sub doSet(ByVal parentCtr As Control)
Dim ctr As Control
For Each ctr In parentCtr.Controls
AddHandler ctr.LostFocus, AddressOf meLostFocus
AddHandler ctr.GotFocus, AddressOf meGotFocus
doSet(ctr)
Next
End Sub
Private Sub meLostFocus(ByVal sender As Object, _
ByVal e As System.EventArgs)
last = DirectCast(sender, Control).Name
End Sub
Private Sub meGotFocus(ByVal sender As Object, _
ByVal e As System.EventArgs)
DirectCast(sender, Control).Text = last
End Sub
///

I hope this gives some idea of going throug a control array?

Cor
Nov 20 '05 #7

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
All controls exist as arrays now (or reference in a control.collections
however that is for me the same, it is uses Ilist).


Well, it is NOT the same as what VB6 called a "control array," and I think
it's confusing to people who have used both to state that there are "control
arrays" in .NET. Most VB6'ers would assume that means that you can have
controls on a form named, for example:

txtData(0)
txtData(1)
txtData(2)
etc.
Nov 20 '05 #8
Jeff,

Did I say it is the same, you said there exist no array of controls in
VBNet.

However that was not the question of the OP. (As you stated already)

I know that it is not what was called in VB6 a control array, luckily not.

However there is the control.collection in every control which implements
from the same class as array does.

:-)

Cor
Well, it is NOT the same as what VB6 called a "control array," and I think
it's confusing to people who have used both to state that there are "control arrays" in .NET. Most VB6'ers would assume that means that you can have
controls on a form named, for example:

txtData(0)
txtData(1)
txtData(2)
etc.

Nov 20 '05 #9

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Did I say it is the same, you said there exist no array of controls in
VBNet.
No, I didn't say "array of controls"; in fact I didn't use the term at all,
at first. The original poster said "control array" and I said they don't
exist in .NET:

-------------------------------------------- Could you explain me,In VB6 using control array,and how
about VB.net.


For VB6, ask in microsoft.public.vb.general.discussion, and for .NET, they
no longer exist.
--------------------------------------------
Nov 20 '05 #10
>
Did I say it is the same, you said there exist no array of controls in
VBNet.
No, I didn't say "array of controls"; in fact I didn't use the term at

all, at first. The original poster said "control array" and I said they don't
exist in .NET:


Yes and it that you are wrong.

Cor
Nov 20 '05 #11

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:eI**************@TK2MSFTNGP11.phx.gbl...
Did I say it is the same, you said there exist no array of controls in
VBNet.


No, I didn't say "array of controls"; in fact I didn't use the term at
all, at first. The original poster said "control array" and I said they don't exist in .NET:


Yes and it that you are wrong.


From MSDN (specifically
http://msdn.microsoft.com/library/de...basicnet.asp):

--------------
In Visual Basic 6.0, control arrays could be used to specify a group of
controls that shared a set of events. The controls had to be of the same
type, and they had to have the same name.

In Visual Basic .NET, control arrays are no longer supported. Changes to the
event model make control arrays unnecessary. Just as control arrays in
Visual Basic 6.0 could share events, the event model in Visual Basic .NET
allows any event handler to handle events from multiple controls. In effect,
this allows you to create groups of controls of disparate types that share
the same events.
--------------

Plain and simple, I don't care if you like to use the terms "array of
controls" and "control arrays" interchangably; the fact is that as far as
Microsoft is concerned they mean different things. We're all professionals
here (for the most part; there are some beginners) and we should be using
correct terminology, especially those of us answering questions, which you
do a lot of (and that's a good thing!). We owe it to the people asking
questions to avoid giving (potentially) confusing advice.
Nov 20 '05 #12

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:eI**************@TK2MSFTNGP11.phx.gbl...
Did I say it is the same, you said there exist no array of controls in
VBNet.


No, I didn't say "array of controls"; in fact I didn't use the term at
all, at first. The original poster said "control array" and I said they don't exist in .NET:


Yes and it that you are wrong.


From MSDN (specifically
http://msdn.microsoft.com/library/de...basicnet.asp):

--------------
In Visual Basic 6.0, control arrays could be used to specify a group of
controls that shared a set of events. The controls had to be of the same
type, and they had to have the same name.

In Visual Basic .NET, control arrays are no longer supported. Changes to the
event model make control arrays unnecessary. Just as control arrays in
Visual Basic 6.0 could share events, the event model in Visual Basic .NET
allows any event handler to handle events from multiple controls. In effect,
this allows you to create groups of controls of disparate types that share
the same events.
--------------

Plain and simple, I don't care if you like to use the terms "array of
controls" and "control arrays" interchangably; the fact is that as far as
Microsoft is concerned they mean different things. We're all professionals
here (for the most part; there are some beginners) and we should be using
correct terminology, especially those of us answering questions, which you
do a lot of (and that's a good thing!). We owe it to the people asking
questions to avoid giving (potentially) confusing advice.
Nov 20 '05 #13
Interesting discussion between you and Mr. Cor. Your last note is interesting in that one can allow the same event handler to handle events from multiple controls. Do you have a code snippet that does this? I don't understand how it's done.
--
Dennis in Houston
"Jeff Johnson [MVP: VB]" wrote:

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:eI**************@TK2MSFTNGP11.phx.gbl...
> Did I say it is the same, you said there exist no array of controls in
> VBNet.

No, I didn't say "array of controls"; in fact I didn't use the term at
all, at first. The original poster said "control array" and I said they don't exist in .NET:


Yes and it that you are wrong.


From MSDN (specifically
http://msdn.microsoft.com/library/de...basicnet.asp):

--------------
In Visual Basic 6.0, control arrays could be used to specify a group of
controls that shared a set of events. The controls had to be of the same
type, and they had to have the same name.

In Visual Basic .NET, control arrays are no longer supported. Changes to the
event model make control arrays unnecessary. Just as control arrays in
Visual Basic 6.0 could share events, the event model in Visual Basic .NET
allows any event handler to handle events from multiple controls. In effect,
this allows you to create groups of controls of disparate types that share
the same events.
--------------

Plain and simple, I don't care if you like to use the terms "array of
controls" and "control arrays" interchangably; the fact is that as far as
Microsoft is concerned they mean different things. We're all professionals
here (for the most part; there are some beginners) and we should be using
correct terminology, especially those of us answering questions, which you
do a lot of (and that's a good thing!). We owe it to the people asking
questions to avoid giving (potentially) confusing advice.

Nov 20 '05 #14
Interesting discussion between you and Mr. Cor. Your last note is interesting in that one can allow the same event handler to handle events from multiple controls. Do you have a code snippet that does this? I don't understand how it's done.
--
Dennis in Houston
"Jeff Johnson [MVP: VB]" wrote:

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:eI**************@TK2MSFTNGP11.phx.gbl...
> Did I say it is the same, you said there exist no array of controls in
> VBNet.

No, I didn't say "array of controls"; in fact I didn't use the term at
all, at first. The original poster said "control array" and I said they don't exist in .NET:


Yes and it that you are wrong.


From MSDN (specifically
http://msdn.microsoft.com/library/de...basicnet.asp):

--------------
In Visual Basic 6.0, control arrays could be used to specify a group of
controls that shared a set of events. The controls had to be of the same
type, and they had to have the same name.

In Visual Basic .NET, control arrays are no longer supported. Changes to the
event model make control arrays unnecessary. Just as control arrays in
Visual Basic 6.0 could share events, the event model in Visual Basic .NET
allows any event handler to handle events from multiple controls. In effect,
this allows you to create groups of controls of disparate types that share
the same events.
--------------

Plain and simple, I don't care if you like to use the terms "array of
controls" and "control arrays" interchangably; the fact is that as far as
Microsoft is concerned they mean different things. We're all professionals
here (for the most part; there are some beginners) and we should be using
correct terminology, especially those of us answering questions, which you
do a lot of (and that's a good thing!). We owe it to the people asking
questions to avoid giving (potentially) confusing advice.

Nov 20 '05 #15

"Dennis" <De****@discussions.microsoft.com> wrote in message
news:81**********************************@microsof t.com...
Interesting discussion between you and Mr. Cor. Your last note is interesting in that one can allow the same event handler to handle events from multiple controls. Do you have a code snippet that does this? I don't understand how it's done.


Sure, but I'm going to be lazy about it: look back in this group for a
thread titled "Handler question" from 2004-07-29 5:41PM (EDT) and read the
responses.
Nov 20 '05 #16

"Dennis" <De****@discussions.microsoft.com> wrote in message
news:81**********************************@microsof t.com...
Interesting discussion between you and Mr. Cor. Your last note is interesting in that one can allow the same event handler to handle events from multiple controls. Do you have a code snippet that does this? I don't understand how it's done.


Sure, but I'm going to be lazy about it: look back in this group for a
thread titled "Handler question" from 2004-07-29 5:41PM (EDT) and read the
responses.
Nov 20 '05 #17
Dennis,

In this thread are two samples from it, use the last one it is recursive and
very handy.

Cor
Nov 20 '05 #18
Jeff,

This is not the first time in this newsgroup that you try to convert VB6 to
VBNet.

The VB6 type control array does luckily not exist in VBNet.

However that does not mean that VBNet has no arrays of controls. You see I
write arrays, because every control (from which the Form is one) has a
control.collection.

http://msdn.microsoft.com/library/de...trolstopic.asp

The reason I take so much time in this thread is that I do not want that
people get the wrong advice and think that because you said "there is no
Control Array in VBNet" the cannot do the things they want to do.

You see seldom the regulars in this newsgroup tell people here in this group
that things cannot be done. And mostly they wait than a long time before
answering. A lot of those things are than even done by our appreciated
cleansweaper Peter Huang who sometimes than even finds a solution or take it
back to his backoffice.

Cor

Cor
Nov 20 '05 #19
Dennis,

In this thread are two samples from it, use the last one it is recursive and
very handy.

Cor
Nov 20 '05 #20
Jeff,

This is not the first time in this newsgroup that you try to convert VB6 to
VBNet.

The VB6 type control array does luckily not exist in VBNet.

However that does not mean that VBNet has no arrays of controls. You see I
write arrays, because every control (from which the Form is one) has a
control.collection.

http://msdn.microsoft.com/library/de...trolstopic.asp

The reason I take so much time in this thread is that I do not want that
people get the wrong advice and think that because you said "there is no
Control Array in VBNet" the cannot do the things they want to do.

You see seldom the regulars in this newsgroup tell people here in this group
that things cannot be done. And mostly they wait than a long time before
answering. A lot of those things are than even done by our appreciated
cleansweaper Peter Huang who sometimes than even finds a solution or take it
back to his backoffice.

Cor

Cor
Nov 20 '05 #21

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Kevin H | last post by:
Apologies in advance if this sounds slow-witted, but I didn't find it here. Need to populate some textboxes on a form. While I could hard code it (the number of options aren't that high), it...
5
by: Blankdraw | last post by:
I can't get this nested loop to break the outer loop at the 5th data value so control can proceed to the next array col and continue pigeon-holing the next 5 in its own column. Why can I not get...
8
by: Brian Keating EI9FXB | last post by:
Would I be correct in saying that the only way to get a user message into a Windows form would be to use P/Invoke with Message? Of is there some part of the .NET API that I am totally un aware...
8
by: Tim | last post by:
On my form I have 10 checkboxes named chkbox1,chkbox2,....chkbox10. I would have like to set it up as an array control like in VB6 where I could have chkbox(1),chkbox(2) but I think .net you have...
3
by: jcrouse | last post by:
I am trying trying to loop through some label controls and setting some properties for the labels I'm looping through. Currently I am addressing the labels one at a time with IF...Then logic, like...
20
by: hufaunder | last post by:
I have 16-bit data that I want to display. In order to display it I compress a certain range of the input data into 8 bit (I need control over this). All seems to work ok except that it is dead...
6
by: Svein Erik | last post by:
C# asp.net 2.0. I'm creating an online survey. I'm making a string array that's holding the variables of the answers made in the radiobuttonlists that i create manually. I need to make a method...
26
by: Alexander Korsunsky | last post by:
Hi! I have some code that looks similar to this: -------------------------------------------- char array = "abcdefghij"; for (int i = 0; i < 10; i++) {
2
by: recordlovelife | last post by:
So I am trying to display a title, date, and content of a wordpress blog. Word press provides nice drop in functions to get the job done with simple names like "the_title", and the "the_content" But...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.