473,769 Members | 5,787 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Scanning Option Group (VB 6 Option Button Control Array)


In VB 6, you can create control arrays for your option groups and scan with
the following code

dim opt as OptionButton
for each opt in OptionGroup
' Do something
next opt

I know VB 2005 doesn't have control arrays, so my question is how do I do
the equivalent in VB 2005?

Thanks,
Mike Ober.

Jun 12 '06 #1
9 5509
Michael,

The difference is that VB6 has no control arrays in the way as they are in
VBNet.
VB6 has only arrays of controls.

In VBNet has every control a collection (array) of the childcontrols it is
using.

Although you can create in VBNet of course as well arrays of controls very
simple even

Dim myControlArray( ) as Control = {Button1, Button2, Textbox3}

I hope this helps,

Cor

Cor

"Michael D. Ober" <obermd.@.alum. mit.edu.nospam> schreef in bericht
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..

In VB 6, you can create control arrays for your option groups and scan
with
the following code

dim opt as OptionButton
for each opt in OptionGroup
' Do something
next opt

I know VB 2005 doesn't have control arrays, so my question is how do I do
the equivalent in VB 2005?

Thanks,
Mike Ober.

Jun 12 '06 #2

When I create the radio group at design time, what steps do I need to do to
be able to loop through the group?

Mike.

"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..

Michael,

The difference is that VB6 has no control arrays in the way as they are in
VBNet.
VB6 has only arrays of controls.

In VBNet has every control a collection (array) of the childcontrols it is
using.

Although you can create in VBNet of course as well arrays of controls very
simple even

Dim myControlArray( ) as Control = {Button1, Button2, Textbox3}

I hope this helps,

Cor

Cor

"Michael D. Ober" <obermd.@.alum. mit.edu.nospam> schreef in bericht
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..

In VB 6, you can create control arrays for your option groups and scan
with
the following code

dim opt as OptionButton
for each opt in OptionGroup
' Do something
next opt

I know VB 2005 doesn't have control arrays, so my question is how do I do the equivalent in VB 2005?

Thanks,
Mike Ober.



Jun 12 '06 #3
Michael,

Depends if it is a radiogroup in a groupbox than you can just do

for each ctr as control in mygroupbox
dim rdb as radiobutton = directcast(ctr, radiobutton)
rdb.blabla
'assuming that there are only radiobuttons otherwise
If typeof ctr Is Radiobutton then
etc.
next

Or code like that.

Cor
"Michael D. Ober"

<obermd.@.alum. mit.edu.nospam> schreef in bericht
news:eO******** ******@TK2MSFTN GP05.phx.gbl...

When I create the radio group at design time, what steps do I need to do
to
be able to loop through the group?

Mike.

"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..

Michael,

The difference is that VB6 has no control arrays in the way as they are
in
VBNet.
VB6 has only arrays of controls.

In VBNet has every control a collection (array) of the childcontrols it
is
using.

Although you can create in VBNet of course as well arrays of controls
very
simple even

Dim myControlArray( ) as Control = {Button1, Button2, Textbox3}

I hope this helps,

Cor

Cor

"Michael D. Ober" <obermd.@.alum. mit.edu.nospam> schreef in bericht
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
>
> In VB 6, you can create control arrays for your option groups and scan
> with
> the following code
>
> dim opt as OptionButton
> for each opt in OptionGroup
> ' Do something
> next opt
>
> I know VB 2005 doesn't have control arrays, so my question is how do I do > the equivalent in VB 2005?
>
> Thanks,
> Mike Ober.
>
>
>



Jun 12 '06 #4
Michael,

Have a look at this page as well. Because that a control can be in a control
do you have to evaluate that inside it, this is easy code to do that.

http://www.vb-tips.com/default.aspx?...6-56e3599238c1

I hope this helps,

Cor
"Michael D. Ober" <obermd.@.alum. mit.edu.nospam> schreef in bericht
news:eO******** ******@TK2MSFTN GP05.phx.gbl...

When I create the radio group at design time, what steps do I need to do
to
be able to loop through the group?

Mike.

"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..

Michael,

The difference is that VB6 has no control arrays in the way as they are
in
VBNet.
VB6 has only arrays of controls.

In VBNet has every control a collection (array) of the childcontrols it
is
using.

Although you can create in VBNet of course as well arrays of controls
very
simple even

Dim myControlArray( ) as Control = {Button1, Button2, Textbox3}

I hope this helps,

Cor

Cor

"Michael D. Ober" <obermd.@.alum. mit.edu.nospam> schreef in bericht
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
>
> In VB 6, you can create control arrays for your option groups and scan
> with
> the following code
>
> dim opt as OptionButton
> for each opt in OptionGroup
> ' Do something
> next opt
>
> I know VB 2005 doesn't have control arrays, so my question is how do I do > the equivalent in VB 2005?
>
> Thanks,
> Mike Ober.
>
>
>



Jun 12 '06 #5

This is what I was looking for.

Thanks, Cor.

"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:eN******** ******@TK2MSFTN GP05.phx.gbl...
Michael,

Depends if it is a radiogroup in a groupbox than you can just do

for each ctr as control in mygroupbox
dim rdb as radiobutton = directcast(ctr, radiobutton)
rdb.blabla
'assuming that there are only radiobuttons otherwise
If typeof ctr Is Radiobutton then
etc.
next

Or code like that.

Cor
"Michael D. Ober"

<obermd.@.alum. mit.edu.nospam> schreef in bericht
news:eO******** ******@TK2MSFTN GP05.phx.gbl...

When I create the radio group at design time, what steps do I need to do
to
be able to loop through the group?

Mike.

"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..

Michael,

The difference is that VB6 has no control arrays in the way as they are
in
VBNet.
VB6 has only arrays of controls.

In VBNet has every control a collection (array) of the childcontrols it
is
using.

Although you can create in VBNet of course as well arrays of controls
very
simple even

Dim myControlArray( ) as Control = {Button1, Button2, Textbox3}

I hope this helps,

Cor

Cor

"Michael D. Ober" <obermd.@.alum. mit.edu.nospam> schreef in bericht
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
>
> In VB 6, you can create control arrays for your option groups and scan > with
> the following code
>
> dim opt as OptionButton
> for each opt in OptionGroup
> ' Do something
> next opt
>
> I know VB 2005 doesn't have control arrays, so my question is how do
I do
> the equivalent in VB 2005?
>
> Thanks,
> Mike Ober.
>
>
>




Jun 12 '06 #6
Any idea what the reasoning was behind that decision?

In VB6 I used to have an array of Buttons and only had to have one
Event Handler with a Select Case statement. Now I have to have ten
different Even Handlers and duplicate a lot of code. Doesn't make
much sense to me unless I'm missing some easier way to do things.
On Mon, 12 Jun 2006 20:14:05 +0200, "Cor Ligthert [MVP]"
<no************ @planet.nl> wrote:
Michael,

The difference is that VB6 has no control arrays in the way as they are in
VBNet.
VB6 has only arrays of controls.

In VBNet has every control a collection (array) of the childcontrols it is
using.

Although you can create in VBNet of course as well arrays of controls very
simple even

Dim myControlArray( ) as Control = {Button1, Button2, Textbox3}

I hope this helps,

Cor

Cor

"Michael D. Ober" <obermd.@.alum. mit.edu.nospam> schreef in bericht
news:%2******* *********@TK2MS FTNGP04.phx.gbl ...

In VB 6, you can create control arrays for your option groups and scan
with
the following code

dim opt as OptionButton
for each opt in OptionGroup
' Do something
next opt

I know VB 2005 doesn't have control arrays, so my question is how do I do
the equivalent in VB 2005?

Thanks,
Mike Ober.

Jun 20 '06 #7

You can add multiple controls to the handler clause on the event handler.
Then you can use a case statement to determine which control triggered the
event.

Mike Ober.

"Kevin" <ke***@nospam.c om> wrote in message
news:30******** *************** *********@4ax.c om...
Any idea what the reasoning was behind that decision?

In VB6 I used to have an array of Buttons and only had to have one
Event Handler with a Select Case statement. Now I have to have ten
different Even Handlers and duplicate a lot of code. Doesn't make
much sense to me unless I'm missing some easier way to do things.
On Mon, 12 Jun 2006 20:14:05 +0200, "Cor Ligthert [MVP]"
<no************ @planet.nl> wrote:
Michael,

The difference is that VB6 has no control arrays in the way as they are inVBNet.
VB6 has only arrays of controls.

In VBNet has every control a collection (array) of the childcontrols it isusing.

Although you can create in VBNet of course as well arrays of controls verysimple even

Dim myControlArray( ) as Control = {Button1, Button2, Textbox3}

I hope this helps,

Cor

Cor

"Michael D. Ober" <obermd.@.alum. mit.edu.nospam> schreef in bericht
news:%2******* *********@TK2MS FTNGP04.phx.gbl ...

In VB 6, you can create control arrays for your option groups and scan
with
the following code

dim opt as OptionButton
for each opt in OptionGroup
' Do something
next opt

I know VB 2005 doesn't have control arrays, so my question is how do I do the equivalent in VB 2005?

Thanks,
Mike Ober.


Jun 20 '06 #8
How would I do this in VB2005?

X = RandomNumber

For Y = 0 to X
Label(Y).BackCo lor = vbGray
Next Y
Now I have Label1, Label2, Label3, etc.
On Tue, 20 Jun 2006 11:35:46 -0600, "Michael D. Ober"
<obermd.@.alum. mit.edu.nospam> wrote:

You can add multiple controls to the handler clause on the event handler.
Then you can use a case statement to determine which control triggered the
event.

Mike Ober.

"Kevin" <ke***@nospam.c om> wrote in message
news:30******* *************** **********@4ax. com...
Any idea what the reasoning was behind that decision?

In VB6 I used to have an array of Buttons and only had to have one
Event Handler with a Select Case statement. Now I have to have ten
different Even Handlers and duplicate a lot of code. Doesn't make
much sense to me unless I'm missing some easier way to do things.
On Mon, 12 Jun 2006 20:14:05 +0200, "Cor Ligthert [MVP]"
<no************ @planet.nl> wrote:
>Michael,
>
>The difference is that VB6 has no control arrays in the way as they arein >VBNet.
>VB6 has only arrays of controls.
>
>In VBNet has every control a collection (array) of the childcontrols itis >using.
>
>Although you can create in VBNet of course as well arrays of controlsvery >simple even
>
>Dim myControlArray( ) as Control = {Button1, Button2, Textbox3}
>
>I hope this helps,
>
>Cor
>
>Cor
>
>"Michael D. Ober" <obermd.@.alum. mit.edu.nospam> schreef in bericht
>news:%2******* *********@TK2MS FTNGP04.phx.gbl ...
>>
>> In VB 6, you can create control arrays for your option groups and scan
>> with
>> the following code
>>
>> dim opt as OptionButton
>> for each opt in OptionGroup
>> ' Do something
>> next opt
>>
>> I know VB 2005 doesn't have control arrays, so my question is how do Ido >> the equivalent in VB 2005?
>>
>> Thanks,
>> Mike Ober.
>>
>>
>>
>


Jun 21 '06 #9
Kevin,

\\\
Dim ctr() As Control = {TextBox1, Button1, label1}
For Each ctrind As Control In ctr
ctrind.BackColo r = Color.Black
Next
///

You find your old method now probably nicer, by most of us did that change.

There are much more methods to identify them by the way even at design time.

Cor

"Kevin" <ke***@nospam.c om> schreef in bericht
news:e8******** *************** *********@4ax.c om...
How would I do this in VB2005?

X = RandomNumber

For Y = 0 to X
Label(Y).BackCo lor = vbGray
Next Y
Now I have Label1, Label2, Label3, etc.
On Tue, 20 Jun 2006 11:35:46 -0600, "Michael D. Ober"
<obermd.@.alum. mit.edu.nospam> wrote:

You can add multiple controls to the handler clause on the event handler.
Then you can use a case statement to determine which control triggered the
event.

Mike Ober.

"Kevin" <ke***@nospam.c om> wrote in message
news:30****** *************** ***********@4ax .com...
Any idea what the reasoning was behind that decision?

In VB6 I used to have an array of Buttons and only had to have one
Event Handler with a Select Case statement. Now I have to have ten
different Even Handlers and duplicate a lot of code. Doesn't make
much sense to me unless I'm missing some easier way to do things.
On Mon, 12 Jun 2006 20:14:05 +0200, "Cor Ligthert [MVP]"
<no************ @planet.nl> wrote:

>Michael,
>
>The difference is that VB6 has no control arrays in the way as they are

in
>VBNet.
>VB6 has only arrays of controls.
>
>In VBNet has every control a collection (array) of the childcontrols it

is
>using.
>
>Although you can create in VBNet of course as well arrays of controls

very
>simple even
>
>Dim myControlArray( ) as Control = {Button1, Button2, Textbox3}
>
>I hope this helps,
>
>Cor
>
>Cor
>
>"Michael D. Ober" <obermd.@.alum. mit.edu.nospam> schreef in bericht
>news:%2******* *********@TK2MS FTNGP04.phx.gbl ...
>>
>> In VB 6, you can create control arrays for your option groups and
>> scan
>> with
>> the following code
>>
>> dim opt as OptionButton
>> for each opt in OptionGroup
>> ' Do something
>> next opt
>>
>> I know VB 2005 doesn't have control arrays, so my question is how do
>> I

do
>> the equivalent in VB 2005?
>>
>> Thanks,
>> Mike Ober.
>>
>>
>>
>


Jun 21 '06 #10

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

Similar topics

9
5057
by: dfg | last post by:
Hello. I have a control Array of option buttons. I'd like to use them in a Case statement, but I can't get it to work. I can only seem to get it working if I use an if-then-else structure, like so: If optFinishType(0) Then TotalAccess = TotalAccess + mcurStandard ElseIf optFinishType(1) Then TotalAccess = TotalAccess + mcurPearl ElseIf optFinishType(2) Then TotalAccess = TotalAccess + mcurDetailing
3
8650
by: Mani | last post by:
Hi, can anyone help me on how to create a control array in C++ builder like we create in VB. I have another question regarding controls. I want to clear a group of text boxes in the form on a button click. I am not using any groupbox. how can i determine the control as Editbox and how can i clear that. any help would be appreciated. thanx
19
2025
by: What-a-Tool | last post by:
I have a school project (ASP) in which I have to call three different ASP pages from three different and identical (except for the form "action", obviously) HTM pages. This I have no problem with. However, as a personal learning project and challenge, I decided to see if I could code my initial HTM page to call any of the three ASP pages, depending on the condition of an option group. (3 buttons - id="function", id="sub", id="class") I...
2
4843
by: Charles | last post by:
Ok, so I'm creating a form on the fly. I can create the option group, I can create the checkboxes, but I can't figure out how to bind them to the option group I'm creating them within. I was hoping the fact that creating them inside the option group would cause it to automatically bind, but no go. As it stands now I create the option group and bind it to a field in a table, then create the checkboxes inside the option group. After that,...
11
4817
by: MLH | last post by:
Why is that? If I choose the tiny check boxes which are hard to hit with a mouse, it works fine. But option buttions, shich can be sized big enough for people with limited sight and dexterity to hit - they don't work at all. Its true. I created 'em with the built-in wizard furnished with Access 97 but they do not work. I put 12 of 'em in the group, labeled the months of the year and giving
3
4301
by: El | last post by:
I can get a total count for a whole option group field, but I need to be able to count each individual selection in an option group on a report. For example if I had a yes or no option...I would need to know how many yes selections there are and how many no selections there are. Please help!!
3
1843
by: kickergirl | last post by:
Is there a way to make an option group a mandatory control on a form? In other words, the user must select yes or no before going to the next control.
2
2890
by: sara | last post by:
Hi I'm having a very strange problem and need HELP!! I have a form for the user to choose a report (radio button in an option group) and parameters (Dates, Season). Click the option button, it turns Black, and the "On Got Focus" event fires. The event shows or hides the parameters appropriate for that report.
11
5297
tuxalot
by: tuxalot | last post by:
Another quick question for ya... Here's my button code, and I want to see if I can do something different so I don't have to repeat the same code for each of my 14 buttons in my option group: Private Sub grpS1_LostFocus() Dim intCount As Integer Dim lngRed As Long, lngBlack As Long lngRed = RGB(186, 20, 25)
0
9583
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10210
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10039
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9860
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8869
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7406
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6668
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3560
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2814
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.