View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default 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?