在 Sub 中停止其他 Sub 运行
有没有办法阻止其他子程序在单独的子程序中运行。
例如说你在子目录中 CreateNumber()
和 subs 的设置类似于
CreateNumber()
添加号码()
?
有没有办法在 CreateNumber() 中调用一个函数来在 createtNumber() 完成后停止 AddNumber 的运行 我只是想让我的程序坐在那里等待事件发生。
Is there a way to stop other subs from running while in a separate sub.
for instance say your in the sub
CreateNumber()
and the subs are setup like
CreateNumber()
AddNumber()
DeleteNumber()
Is there a way to be in CreateNumber() and call a function to stop AddNumber from running after creaetNumber() is finished? i just want my program to sit there to wait for an event to happen.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需这样做:
如果您不使用线程,那么这些 Subs 将简单地按顺序调用,因此您不必做任何“聪明”的事情。
如果你想让CreateNumber能够控制是否执行AddNumber(),那么你可以将它做成一个Function并返回一个结果 - 例如
然后这样调用它:
这样,你只调用剩余的Subs,如果CreateNumber() 返回 True。
Just do this:
If you're not using threads, then these Subs will simply be called in sequence, so you don't have to do anything "clever".
If you want CreateNumber to be able to control whether or not AddNumber() will be executed, then you can make it into a Function and return a result - e.g.
Then call it like this:
In this way, you only call the remaining Subs if CreateNumber() returned True.