S
Steve
Hi,
I learned programming on VB5 and am now trying to get used to using control
collections instead of control arrays.
I have a set of 50 labels, labelled "Label1" "Label2" etc. I so far have the
code:
Dim intIndex As Integer
For intIndex = 0 To Me.Controls.Count - 1
If Left(Me.Controls(intIndex).Name, 1) = "L" Then
Me.Controls.(IntIndex).ForeColor = &H8000000D
Next intIndex
This selects all the labels and turns the text blue. I know the coding is a
bit sloppy but I'm okay with it. What I want to do though is find a way of
getting the labels to share the code as you could with control arrays, and
then get the program to be able to identify which label has been clicked on.
My goal is that any label is clicked on it will set the caption to the value
I have in a separately defined array.
To give a simply example:
myarray(1)="This is label1"
myarray(2)="This is label2"
Me.Controls(Index).Caption=myarray(index)
where index represents the collection index of the particular label that has
been clicked. I know that I could write out 50 separate pieces of code for
each label and just change the code manually but I was really hoping to avoid
this.
Any solutions would be great! Thanks
I learned programming on VB5 and am now trying to get used to using control
collections instead of control arrays.
I have a set of 50 labels, labelled "Label1" "Label2" etc. I so far have the
code:
Dim intIndex As Integer
For intIndex = 0 To Me.Controls.Count - 1
If Left(Me.Controls(intIndex).Name, 1) = "L" Then
Me.Controls.(IntIndex).ForeColor = &H8000000D
Next intIndex
This selects all the labels and turns the text blue. I know the coding is a
bit sloppy but I'm okay with it. What I want to do though is find a way of
getting the labels to share the code as you could with control arrays, and
then get the program to be able to identify which label has been clicked on.
My goal is that any label is clicked on it will set the caption to the value
I have in a separately defined array.
To give a simply example:
myarray(1)="This is label1"
myarray(2)="This is label2"
Me.Controls(Index).Caption=myarray(index)
where index represents the collection index of the particular label that has
been clicked. I know that I could write out 50 separate pieces of code for
each label and just change the code manually but I was really hoping to avoid
this.
Any solutions would be great! Thanks