Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Calling an eventprocedure
I have a userform with a textbox. How do I call the _Exit procedure
(TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) ) for this textbox from another procedure? I am trying to do this: Sub Another() If Not Test Then ' Boolean test fails ' Call the exit procedure for the textbox Call TextBox_Exit ' Here I get an error End Sub Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) (do something clever) End Sub Anybody? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Calling an eventprocedure
Where is the Sub Another located?
Sub Another() If Not Test Then ' Boolean test fails ' Call the exit procedure for the textbox Call Userform1.TextBox_Exit ' Here I get an error End Sub ' note: declare public if Another is outside useform module Public Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) (do something clever) End Sub possibly is what you want. Easier to put common code like this in a separate sub Sub TakeAction() ' do something clever end Sub Sub Another() If Not Test Then ' Boolean test fails TakeAction End if End Sub Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) TakeAction End Sub -- Regards, Tom Ogilvy "Hans Petter" wrote in message ... I have a userform with a textbox. How do I call the _Exit procedure (TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) ) for this textbox from another procedure? I am trying to do this: Sub Another() If Not Test Then ' Boolean test fails ' Call the exit procedure for the textbox Call TextBox_Exit ' Here I get an error End Sub Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) (do something clever) End Sub Anybody? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Calling an eventprocedure
Both subs are in the same userform module. My first impulse was to create a
workaround with TakeAction as you describe. I did not make it work because I have to alter the Boolean Cancel. If user input is not valid, the Event status must be assigned True to prevent the control from losing focus, and in this particular case, I have to trigger the _Exit event from another sub, not by the event itself. The Call Userform1.TextBox_Exit did not work. When I try this: Call TextBox_Exit the error message is: Argument not optional To narrow it down, I understand there has to be passed over an argument to the Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) procedure / event. I have tried to pass over a module level Cancelled, but get the error message Type mismatch. Is there a way I can set the event status from outside the _Exit sub/event? Or what argument has to be passed to the _Exit sub/event? I have looked at the RaiseEvent statement, but the _Exit sub/event is not explicitly declared in the form module, and can not be used Thank you for answering Where is the Sub Another located? Sub Another() If Not Test Then ' Boolean test fails ' Call the exit procedure for the textbox Call Userform1.TextBox_Exit ' Here I get an error End Sub ' note: declare public if Another is outside useform module Public Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) (do something clever) End Sub possibly is what you want. Easier to put common code like this in a separate sub Sub TakeAction() ' do something clever end Sub Sub Another() If Not Test Then ' Boolean test fails TakeAction End if End Sub Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) TakeAction End Sub -- Regards, Tom Ogilvy "Hans Petter" wrote in message ... I have a userform with a textbox. How do I call the _Exit procedure (TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) ) for this textbox from another procedure? I am trying to do this: Sub Another() If Not Test Then ' Boolean test fails ' Call the exit procedure for the textbox Call TextBox_Exit ' Here I get an error End Sub Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) (do something clever) End Sub Anybody? |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Calling an eventprocedure
If the event is not being triggered by the user exiting the textbox or
whatever control it is, I am not sure setting cancel to false would have any effect. -- Regards, Tom Ogilvy "Hans Petter" wrote in message ... Both subs are in the same userform module. My first impulse was to create a workaround with TakeAction as you describe. I did not make it work because I have to alter the Boolean Cancel. If user input is not valid, the Event status must be assigned True to prevent the control from losing focus, and in this particular case, I have to trigger the _Exit event from another sub, not by the event itself. The Call Userform1.TextBox_Exit did not work. When I try this: Call TextBox_Exit the error message is: Argument not optional To narrow it down, I understand there has to be passed over an argument to the Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) procedure / event. I have tried to pass over a module level Cancelled, but get the error message Type mismatch. Is there a way I can set the event status from outside the _Exit sub/event? Or what argument has to be passed to the _Exit sub/event? I have looked at the RaiseEvent statement, but the _Exit sub/event is not explicitly declared in the form module, and can not be used Thank you for answering Where is the Sub Another located? Sub Another() If Not Test Then ' Boolean test fails ' Call the exit procedure for the textbox Call Userform1.TextBox_Exit ' Here I get an error End Sub ' note: declare public if Another is outside useform module Public Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) (do something clever) End Sub possibly is what you want. Easier to put common code like this in a separate sub Sub TakeAction() ' do something clever end Sub Sub Another() If Not Test Then ' Boolean test fails TakeAction End if End Sub Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) TakeAction End Sub -- Regards, Tom Ogilvy "Hans Petter" wrote in message ... I have a userform with a textbox. How do I call the _Exit procedure (TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) ) for this textbox from another procedure? I am trying to do this: Sub Another() If Not Test Then ' Boolean test fails ' Call the exit procedure for the textbox Call TextBox_Exit ' Here I get an error End Sub Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) (do something clever) End Sub Anybody? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
calling a module | Excel Discussion (Misc queries) | |||
HELP!!!! Calling a sub from Workbook_BeforeSave | Excel Discussion (Misc queries) | |||
Calling an Add-In | Excel Discussion (Misc queries) | |||
Calling Sub / Called Sub | Excel Programming | |||
Calling SUB | Excel Programming |