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.
4 1978
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
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
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.
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).
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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,...
|
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...
|
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...
|
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...
|
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...
|
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
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
|
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,...
| | |