Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
art art is offline
external usenet poster
 
Posts: 22
Default Ending a routine

I want to present a messagebox to the user that allows him
to cancel and get completely out of the "program". Exit
Sub is not enough because the messagebox has been called
from another sub. How do I do this?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 538
Default Ending a routine

On Mon, 27 Oct 2003 02:20:48 -0800, art <[email deleted] wrote:

I want to present a messagebox to the user that allows him
to cancel and get completely out of the "program". Exit
Sub is not enough because the messagebox has been called
from another sub. How do I do this?


Change the sub with the msgbox into a function, and instead of just
calling it from the other sub, check its return value, which you set
based on the return value of the msgbox. Here's an example:
Sub bar()
If Not foo Then Exit Sub
'or, assigned to a variable:
y = foo
If Not y Then Exit Sub 'or if y=false
End Sub

Function foo() As Boolean
x = MsgBox("blah", vbOKCancel)
If x = vbCancel Then
foo = False
Exit Function
End If
'...
foo = True
End Function
--
auric "underscore" "underscore" "at" hotmail "dot" com
*****
Professional wrestling: ballet for the common man.
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
sub routine Gord Dibben Excel Discussion (Misc queries) 0 November 13th 09 12:15 AM
Worksheet_Change sub routine Gandalph New Users to Excel 1 April 5th 08 01:02 PM
How to create a routine Tara Excel Discussion (Misc queries) 1 August 12th 05 02:28 AM
Solver VBA routine KLM Excel Discussion (Misc queries) 4 August 11th 05 11:51 AM
Need VBA Routine John M. Lembo Excel Programming 0 July 13th 03 01:51 AM


All times are GMT +1. The time now is 08:50 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"