vba如何终止执行
<p>sub A()中调用的函数function B() <br/>function B()内出现错误,捕获之后我用msgbox()提示,想在确认后停止整个sub A()的运行,请问各位高人该如何实现?</p><p>sub A()<br/>……<br/>a=function B()<br/>……<br/>end sub </p><p>function B()<br/>……<br/>on error goto myerror<br/>……<br/>myerror:<br/> msgbox("输入错误,请检查")<br/>???????<br/>end function</p><p>“???????”部分不知如何实现</p> <div style="WIDTH: 728px; HEIGHT: 90px;"><script type="text/javascript"></script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script><iframe name="google_ads_frame" marginwidth="0" marginheight="0" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-7471407183047897&dt=1208755141500&lmt=1208755141&prev_fmts=728x90_as%2C120x90_0ads_al_s&format=728x90_as&output=html&correlator=1208755139265&channel=9653521252&pv_ch=9653521252%2B&url=http%3A%2F%2Fwww.mjtd.com%2FBBS%2Fdispbbs.asp%3FboardID%3D4%26ID%3D67208%26page%3D1&color_bg=FFFFFF&color_text=000000&color_link=0000FF&color_url=008000&color_border=C3D9FF&ad_type=text_image&ref=http%3A%2F%2Fwww.mjtd.com%2FBBS%2Flogin.asp&frm=0&cc=100&ga_vid=1255804713.1208754695&ga_sid=1208754695&ga_hid=1388894835&ga_fc=true&flash=0&u_h=768&u_w=1024&u_ah=738&u_aw=1024&u_cd=32&u_tz=480&u_his=4&u_java=true" frameborder="0" width="728" scrolling="no" height="90" allowtransparency="allowtransparency"></iframe></div><p>sub A()中调用的函数function B() <br/>function B()内出现错误,捕获之后我用msgbox()提示,想在确认后停止整个sub A()的运行,请问各位高人该如何实现?</p><p>sub A()<br/>……<br/>a=function B()<br/>s:if m=0 then exit sub;end sub </p><p>function B()<br/>……<br/>on error goto myerror<br/>……<br/>myerror:<br/> m=msgbox("输入错误,请检查")<br/>if m=0; 即点击了OK</p><p>goto s<br/>end function</p><p></p><p>或者function B()有返回值的话</p><p>sub A()<br/><br/>……<br/>a=function B()<br/>if a=0 then exit sub</p><p>function B()<br/>……<br/>on error goto myerror<br/>……<br/>myerror:<br/> m=msgbox("输入错误,请检查")<br/>end function;让funciton B()返回0</p><p></p><p>大概就是这么个意思代码,自己再改改吧</p> <p>好方法!谢过啦!</p><p>也就是说VBA里面是没有停止运行的语句啦?不知是不是这样?</p>
页:
[1]