Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Changing Event Subs of Controls On Air

Hi,

I'm designing a userform with several controls (Textboxes, Comboboxes,
CommandButtons etc.). But I create some controls on air via code. I want to
assign some subs ON AIR to control's event procs like On Enter, On Change,
On Exit... Does anybody know how can I do that? Thanks in advance...




--
Regards

Haldun Alay

To e-mail me, please remove AT and DOT from my e-mail address.




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Changing Event Subs of Controls On Air

Check out Chip Pearson's site
http://www.cpearson.com/excel/vbe.htm

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Haldun Alay" <haldunalayATyahooDOTcom wrote in message ...
Hi,

I'm designing a userform with several controls (Textboxes, Comboboxes,
CommandButtons etc.). But I create some controls on air via code. I want to
assign some subs ON AIR to control's event procs like On Enter, On Change,
On Exit... Does anybody know how can I do that? Thanks in advance...




--
Regards

Haldun Alay

To e-mail me, please remove AT and DOT from my e-mail address.






  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Changing Event Subs of Controls On Air

Hi Ron,

Thanks for your reply.

I try the codes on the site that you adviced but the problem is still exist.

For example I have a textbox control : TextBox1 and it's event sub
TextBox1_Enter() already defined.
Also I have one sub called AssignThis() in userform's code. What I want to
do is, While running userform, in some conditions I want to change
TextBox1's OnEnter event's sub to AssignThis via versa. On that site it
shows how to add events whose are not exist.


--
Regards

Haldun Alay

To e-mail me, please remove AT and DOT from my e-mail address.



"Ron de Bruin" , iletide şunu yazdı
...
Check out Chip Pearson's site
http://www.cpearson.com/excel/vbe.htm

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Haldun Alay" <haldunalayATyahooDOTcom wrote in message

...
Hi,

I'm designing a userform with several controls (Textboxes, Comboboxes,
CommandButtons etc.). But I create some controls on air via code. I want

to
assign some subs ON AIR to control's event procs like On Enter, On

Change,
On Exit... Does anybody know how can I do that? Thanks in advance...




--
Regards

Haldun Alay

To e-mail me, please remove AT and DOT from my e-mail address.








  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Changing Event Subs of Controls On Air

Here is a example for delete and add a sub
Delete it first and add a new one

You can use this for events also

Sub AddProcedure()
Dim VBCodeMod As CodeModule
Dim LineNum As Long

Set VBCodeMod = ThisWorkbook.VBProject.VBComponents("Sheet1").Code Module
With VBCodeMod
LineNum = .CountOfLines + 1
.InsertLines LineNum, _
"Sub MyNewProcedure()" & Chr(13) & _
" Msgbox ""Here is the new procedure"" " & Chr(13) & _
"End Sub"
End With
End Sub


Sub DeleteProcedure()
Dim VBCodeMod As CodeModule
Dim StartLine As Long
Dim HowManyLines As Long

Set VBCodeMod = ThisWorkbook.VBProject.VBComponents("Sheet1").Code Module
With VBCodeMod
StartLine = .ProcStartLine("MyNewProcedure", vbext_pk_Proc)
HowManyLines = .ProcCountLines("MyNewProcedure", vbext_pk_Proc)
.DeleteLines StartLine, HowManyLines
End With
End Sub



--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Haldun Alay" <haldunalayATyahooDOTcom wrote in message ...
Hi Ron,

Thanks for your reply.

I try the codes on the site that you adviced but the problem is still exist.

For example I have a textbox control : TextBox1 and it's event sub
TextBox1_Enter() already defined.
Also I have one sub called AssignThis() in userform's code. What I want to
do is, While running userform, in some conditions I want to change
TextBox1's OnEnter event's sub to AssignThis via versa. On that site it
shows how to add events whose are not exist.


--
Regards

Haldun Alay

To e-mail me, please remove AT and DOT from my e-mail address.



"Ron de Bruin" , iletide şunu yazdı
...
Check out Chip Pearson's site
http://www.cpearson.com/excel/vbe.htm

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Haldun Alay" <haldunalayATyahooDOTcom wrote in message

...
Hi,

I'm designing a userform with several controls (Textboxes, Comboboxes,
CommandButtons etc.). But I create some controls on air via code. I want

to
assign some subs ON AIR to control's event procs like On Enter, On

Change,
On Exit... Does anybody know how can I do that? Thanks in advance...




--
Regards

Haldun Alay

To e-mail me, please remove AT and DOT from my e-mail address.










Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Combo Box text and Controls changing size on Monitor change Richhall[_2_] Excel Worksheet Functions 0 January 12th 10 12:38 PM
Changing sheets after the DeActivate Event. Richard Excel Discussion (Misc queries) 2 July 10th 08 03:49 PM
how can I trap the change event (Tab Press key) of these controls Padam Excel Worksheet Functions 1 August 10th 06 03:59 PM
how can I trap the change event (Tab Press key) of these controls Padam Excel Worksheet Functions 0 August 10th 06 02:41 PM
Same event procedure for multiple controls Mikhail Excel Programming 1 October 13th 03 03:23 PM


All times are GMT +1. The time now is 10:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"