View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ouka[_17_] Ouka[_17_] is offline
external usenet poster
 
Posts: 1
Default Assign click functionality to dynamically created textboxes?


Hi all,

I have a userform that has textboxes that are created and populate
dynamically at runtime.

i.e.: based on the number of cells found to be populated with data o
a spreadsheet, I create a userform with textboxes with value
cooresponding to those cells

I want to add the ability to double click on these textboxes and hav
the value changed to the current date being displayed by a calande
control that is also built into my userform.

But since don't know how many textboxes are going to be created on
given execution of the code, I can't just make the subs that woul
normally control click actions.

Say there were 2 textboxes being created, I'd then need:

Sub Textbox1_dblclick(ByVal Cancel as MSForms.ReturnBoolean)
Textbox1 = calendar1
End sub
-----------------------------------
Sub Textbox2_dblclick(ByVal Cancel as MSForms.ReturnBoolean)
Textbox2 = calendar1
End sub

But if I have 5 textboxes, I'd need 5 subs. If 10, then 10. etc.

Is there any way to include a variable as part of a sub's name?

Like say:

Sub Controls("Textbox" & N)_dblClick(ByVal Cancel A
MSForms.ReturnBoolean)

with the value for N being passed by another procedure during th
intial building of the userform

--
Ouk
-----------------------------------------------------------------------
Ouka's Profile: http://www.excelforum.com/member.php...fo&userid=2398
View this thread: http://www.excelforum.com/showthread.php?threadid=39800