PDA

View Full Version : I need help with a click proceedure attached to a dynamic label



shanec
06-13-2009, 02:53 AM
i have created some dynamic labels on a userform however when i go to link them to with let’s say line1_click it does not recognize it albeit i know that label is definitely there. Is there a setting or something i am missing in the properties.

This is how the label is created

....Set newlabel = Statistics_Form3.Controls.Add("Forms.label.1", "line" & labelnumber, True)


thanks for looking at this

Shanec

Simon Lloyd
06-13-2009, 02:03 PM
Can you supply a sample workbook?

shanec
06-13-2009, 02:33 PM
Hi Simon,

thanks for answering my post. I have made a little progress in the form that i now know i need to add an "event handler", as you can tell i am quite new at this.

I found this, AddHandler Button1.Click, AddressOf Button1_Click on a Microsoft site and am trying to figure how it will work with my lableing creating code above.

I changed it to AddHandler line7.Click, AddressOf line7_Click and get an invalid use of address compile error

Thanks again

shanec
06-13-2009, 02:42 PM
Just found out that AddHandler label7.Click, AddressOf label7_Click does not work in excel........

lucas
06-13-2009, 03:26 PM
Don't be defensive but why create controls on the fly? This always happens when you do.

shanec
06-13-2009, 04:45 PM
Hi lucus thanks so much for answering my message. Given that i have sometimes up to 300 labels on a screen at one time i wrote a routine that adds them dynamically positions them to where i want and fills them from arrayed information, the same routine works for about 30 programs/routines and i just call a simple sub.

i have found a work around some code in the "custom class module" although it not a clean as i would have liked, it doeas have the potential to light up any or all of the labels.

again thanks

Shane