How to elegantly end a main procedure from a userform command button?

A

akh2103

Hello--I am looking for a tidy way to end a main procedure from a
userform command button. One idea that might work (say the newsgroups)
is to to run a boolean function procedure that returns a value, False
if certain conditions are met. Then one could check for a false value
in the main procedure before continuing. However, I am having trouble
connecting userform buttons with function rather than sub procedures. I
am sure that this is a common problem. Can anyone suggest an elegant
way out? Thanks. -Abe
 
G

Guest

Whe you click the button have the button click procedure run your boolean
functions to determine the proper course of action...

Private Sub CommandButton1_Click()
if this = false then exit sub
if That = true then
msgbox "Sorry but it's time to go now..."
else
'do your stuff
end if
End Sub

private function This() as boolean
This = True
end function

private function That() as boolean
That = False
end function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top