Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a form with multiple textboxes. When initializing the form, I use
values from the worksheet to fill the textboxes. Each of these initialization steps triggers the TextBox_Change event, which is unnecessary during the initialization. Can I easily stop the TextBox_Change event during this initialization? The code following works, but seems a little bulky and I would prefer something more efficient or eloquent. Oh, and it's a pain to have to write the TextBox_Change code over and over for multiple textboxes. What I have done is this (with x being a public variable): x = false ....code that triggers Textbox_Change x=true Textbox_Change If x = true then ....code Else 'do nothing End If Thanks, drhalter |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
That's basically what you have to do. I usually scope my variable to the
code module. I also call it bEnableEvents to mimic the Application.EnableEvents property which doesn't affect UserForm events. If you like, you could even use Application.EnableEvents, and do your UserForm event procedures this way: Private Sub Textbox1_Change() If Application.EnableEvents Then ' your code goes here End If End Sub - Jon ------- Jon Peltier, Microsoft Excel MVP Tutorials and Custom Solutions Peltier Technical Services, Inc. - http://PeltierTech.com _______ "drhalter" wrote in message ... I have a form with multiple textboxes. When initializing the form, I use values from the worksheet to fill the textboxes. Each of these initialization steps triggers the TextBox_Change event, which is unnecessary during the initialization. Can I easily stop the TextBox_Change event during this initialization? The code following works, but seems a little bulky and I would prefer something more efficient or eloquent. Oh, and it's a pain to have to write the TextBox_Change code over and over for multiple textboxes. What I have done is this (with x being a public variable): x = false ...code that triggers Textbox_Change x=true Textbox_Change If x = true then ...code Else 'do nothing End If Thanks, drhalter |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Wow, that's a pain. I even have some code listed now
If x = true then x = false ...code (which would trigger another TextBox_Change event, but since x is false, it skips the code) x = true End If Thanks for the info! drhalter "Jon Peltier" wrote: That's basically what you have to do. I usually scope my variable to the code module. I also call it bEnableEvents to mimic the Application.EnableEvents property which doesn't affect UserForm events. If you like, you could even use Application.EnableEvents, and do your UserForm event procedures this way: Private Sub Textbox1_Change() If Application.EnableEvents Then ' your code goes here End If End Sub - Jon ------- Jon Peltier, Microsoft Excel MVP Tutorials and Custom Solutions Peltier Technical Services, Inc. - http://PeltierTech.com _______ "drhalter" wrote in message ... I have a form with multiple textboxes. When initializing the form, I use values from the worksheet to fill the textboxes. Each of these initialization steps triggers the TextBox_Change event, which is unnecessary during the initialization. Can I easily stop the TextBox_Change event during this initialization? The code following works, but seems a little bulky and I would prefer something more efficient or eloquent. Oh, and it's a pain to have to write the TextBox_Change code over and over for multiple textboxes. What I have done is this (with x being a public variable): x = false ...code that triggers Textbox_Change x=true Textbox_Change If x = true then ...code Else 'do nothing End If Thanks, drhalter |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Quick hint:
Instead of If x = true then you could simply use If x then - Jon ------- Jon Peltier, Microsoft Excel MVP Tutorials and Custom Solutions Peltier Technical Services, Inc. - http://PeltierTech.com _______ "drhalter" wrote in message ... Wow, that's a pain. I even have some code listed now If x = true then x = false ...code (which would trigger another TextBox_Change event, but since x is false, it skips the code) x = true End If Thanks for the info! drhalter "Jon Peltier" wrote: That's basically what you have to do. I usually scope my variable to the code module. I also call it bEnableEvents to mimic the Application.EnableEvents property which doesn't affect UserForm events. If you like, you could even use Application.EnableEvents, and do your UserForm event procedures this way: Private Sub Textbox1_Change() If Application.EnableEvents Then ' your code goes here End If End Sub - Jon ------- Jon Peltier, Microsoft Excel MVP Tutorials and Custom Solutions Peltier Technical Services, Inc. - http://PeltierTech.com _______ "drhalter" wrote in message ... I have a form with multiple textboxes. When initializing the form, I use values from the worksheet to fill the textboxes. Each of these initialization steps triggers the TextBox_Change event, which is unnecessary during the initialization. Can I easily stop the TextBox_Change event during this initialization? The code following works, but seems a little bulky and I would prefer something more efficient or eloquent. Oh, and it's a pain to have to write the TextBox_Change code over and over for multiple textboxes. What I have done is this (with x being a public variable): x = false ...code that triggers Textbox_Change x=true Textbox_Change If x = true then ...code Else 'do nothing End If Thanks, drhalter |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
TextBox_Change a little premature! | Excel Programming | |||
suspend a routine | Excel Programming | |||
Suspend Execution | Excel Programming | |||
Suspend code | Excel Programming | |||
Screen suspend | Excel Programming |