473,386 Members | 1,706 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,386 software developers and data experts.

control array events

13
In VB6, I want to create a control array (labels) at startup and then be able to have one event procedure (click) for all of them that returns an index. This works with the copy-paste method of making a label array, but i have over 100 labels and don't want to copy-paste anyways. the code i have is as follows:

__________________________________________________ ________________

(General)
Dim Square() as Control

(Load)
Redim Square(0 to Num)

For count = 0 to num
Set Square(count) = VB.Controls.Add("VBLabel", "Square" & count, "frmForm")
With Square(count)
'position in form
end With
next

' section 1
Private Sub Square()_Click(Index as Integer. Button as integer, Shift as Integer...etc.)
square(index).caption = button
end sub
__________________________________________________ ________________

The exact same code in section 1 works if the array is instead copy-pasted. Currently, the labels display correctly, but nothing happens when i click on them (section 1). Any help is appreciated.
Sep 27 '07 #1
2 1376
Killer42
8,435 Expert 8TB
The easy way is to create the control array at design time with a single entry (index 0) and create the event procedures for it. Then at runtime, you just use the Load statement to add more entries to the control array.
Sep 27 '07 #2
vfiroiu
13
Thanks Killer42, but could you please shop me the specific code for doing that? That would help alot. thanks.
Oct 2 '07 #3

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

Similar topics

6
by: Christian H | last post by:
Hi! I've created a custom control (myDrawControl) that deals with drawing. This control is then added to a form( myMainForm) Now, whenever something is dragged and dropped onto myDrawControl ,...
3
by: Christopher | last post by:
Hi I need to know how to work with a control array in c#. I would like to clear the contents of a textbox array after adding up the values in the textboxes. This is really easy in VB6 - im sure...
0
by: Charles A. Lackman | last post by:
Hello, I have created a User Control within Visual Studio and it contains a button that allows the user to querry a database. I dynamically add additional controls to the page based on the...
13
by: Bernie | last post by:
Sorry, but this ia another whine about VB.Net's lack of Control Arrays. I am new to VB.Net and I'm building an application that uses variable number of Label controls that are created at run...
20
by: samean | last post by:
Hello, Could you explain me,In VB6 using control array,and how about VB.net. Thanks
9
by: Jay | last post by:
Why is it publisized that VB.NET does not support control arrays? This is not true. It is just that it is implemented in another way. Dim txtNumbers(10) as TextBox Everything must be done...
1
by: coderjoe | last post by:
I'm new to VB.Net and I'm using the 2003 version. I created a user control that has two labels on it. The two labels are side by side. The first is bold font and will be used to display a line...
2
by: Mike | last post by:
Hi, I am strugling with a simple problem which I can't seem to resolve. I have an asp.net page which contains a server-control (flytreeview, which is a kind of a tree to be exact). The tree is...
13
by: Just_a_fan | last post by:
I am adding a bunch of controls with the code below. Problem 1: When program flow passes to "UpperChanged" when I click it, the control name is undefined. When I enter: If udUpperLim1.Value 1...
9
by: README | last post by:
so what i need to do is implement a code that will take the maximum number in a array and put it into another array. events is an array that contains numbers that was extracted from a file. Count...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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...
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
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,...
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...

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.