473,508 Members | 2,357 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Array of buttons, each one using a common procedure

3 New Member
I have an array of 16 control buttons. Their click routines set a unique identifier code. All buttons then vector to a common procedure. How do I relate the identifier to the Button object i.e. If I press button 15, I need to operate on btnChannel15, if button 3, on btnChannel3, etc. (how do I incorporate a variable component into each Button Object's name)? I'm relatively new to VB, and a newbie to this forum, so I'd appreciate any pointers in the right direction.
Mar 24 '07 #1
4 1980
vijaydiwakar
579 Contributor
I have an array of 16 control buttons. Their click routines set a unique identifier code. All buttons then vector to a common procedure. How do I relate the identifier to the Button object i.e. If I press button 15, I need to operate on btnChannel15, if button 3, on btnChannel3, etc. (how do I incorporate a variable component into each Button Object's name)? I'm relatively new to VB, and a newbie to this forum, so I'd appreciate any pointers in the right direction.
use index property like
if index=1 then ' code
this index is inbuilt in function whenevr u create ctrl array
Mar 24 '07 #2
SammyB
807 Recognized Expert Contributor
I have an array of 16 control buttons. Their click routines set a unique identifier code. All buttons then vector to a common procedure. How do I relate the identifier to the Button object i.e. If I press button 15, I need to operate on btnChannel15, if button 3, on btnChannel3, etc. (how do I incorporate a variable component into each Button Object's name)? I'm relatively new to VB, and a newbie to this forum, so I'd appreciate any pointers in the right direction.
What VB are you using: VBA (as part of an Office application such as Access), VB6, VB.NET 2003, or VB.NET 2005?

BTW, welcome to The Scripts, like you I am a gray beard, except mine is much grayer: started 1962 on an IBM 1410

Mar 24 '07 #3
grayb
3 New Member
What VB are you using: VBA (as part of an Office application such as Access), VB6, VB.NET 2003, or VB.NET 2005?

BTW, welcome to The Scripts, like you I am a gray beard, except mine is much grayer: started 1962 on an IBM 1410

Thanks for the response. I'm using VB.NET, but I think it's slightly before 2003, although it seems pretty compatible with my copy of Halvorson's "Visual Basic.net Step By Step," which is on the 2003 product.
Mar 26 '07 #4
Killer42
8,435 Recognized Expert Expert
I have an array of 16 control buttons. Their click routines set a unique identifier code. All buttons then vector to a common procedure. How do I relate the identifier to the Button object i.e. If I press button 15, I need to operate on btnChannel15, if button 3, on btnChannel3, etc. (how do I incorporate a variable component into each Button Object's name)? I'm relatively new to VB, and a newbie to this forum, so I'd appreciate any pointers in the right direction.
Ironically, VB6 had exactly the functionality you need. You could allocate controls in an array, with all the functionality that implies - loop processing, a single event procedure which receives an index to identify which control produced the event, and so on.

For reasons I have been unable to fathom (does anyone know?) M$ decided to remove this incredibly useful feature in VBA (probably understandable) and VB.Net.

There has been quite a bit of posting here on the topic of simulating a control array. The basic technique, as suggested (I think) by M$ is to set control names with a number on the end as you have done, and use various bits of code to translate back and forth.

I recently proposed an alternative method, right here on TheScripts. :D The idea is to define an array of a generic type such as Object or (assuming it’s available in .Net) Control, and start out at form load by setting each of the elements in the array to point to one of your “array” of controls. The technique has not been fully investigated, as I haven’t had the time, but the basic idea should be sound. And it should allow you to access your controls using proper array processing.

Try a search (see the search box, top-right of the page) of TheScripts for terms such as “VB simulate control array” - you should find plenty of info to get you started.

Incidentally, I'm not quite the "greybeard" you claim to be, but have been dabbling with VB since version 1. Haven't made it past VB6, though. I plan to start looking into the .Net version "real soon now". Probably the 2003 version, since I already have that (got it as part of an MSDN subscription).
Mar 26 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
10877
by: Michael Trosen | last post by:
Hi Everyone, I hope someone can help, I'm pretty new to pro*c programming. I have the following application setup: a pro*c program calls a stored procedure and recieves a cursor back: the...
10
5586
by: serge | last post by:
Using "SELECT * " is a bad practice even when using a VIEW instead of a table? I have some stored procedures that are identical with the difference of one statement in the WHERE clause. If I...
5
5031
by: Lyn | last post by:
Hi, I hope someone can help. I have a main form which mostly fills the Access window. In the bottom half of this form I have a tab control to display various types of data related to the main...
5
1525
by: Edwinah63 | last post by:
Hi everyone, i was wondering if anyone else had observed this and if there is any workaround or patch. i have some screens (an mdi child forms) with the buttons &Add, &Edit, &Save and E&xit,...
10
1582
by: Tor Inge Rislaa | last post by:
Creating Control Array How to create an array of buttons, with common procedures based on the index of the control. How would this Example from VB 6.0 be in VB.NET? Private Sub...
7
4236
by: Geoff Jones | last post by:
Hi I'm hoping that someone can help me with the following question about Radio Buttons. In MFC there is a way of attaching a variable to several radio buttons so that it can be looked at to...
4
9668
by: mflll | last post by:
I am looking into the different techniques of handling arrays of edit boxes in Java Script. The first program below works fine. However, are there better ways of doing this, where the person...
272
13873
by: Peter Olcott | last post by:
http://groups.google.com/group/comp.lang.c++/msg/a9092f0f6c9bf13a I think that the operator() member function does not work correctly, does anyone else know how to make a template for making two...
6
1446
by: saulij | last post by:
I have an array of buttons. There is a common Click-method for these buttons. How can I find what button is clicked? Sauli
1
7039
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
7494
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...
0
5626
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,...
1
5050
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...
0
4706
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...
0
3180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1553
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
415
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...

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.