当用户中途停止循环时重新启动循环 [英] Restarting a loop when the user stops it halfway through

查看:74
本文介绍了当用户中途停止循环时重新启动循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我尝试修改的程序的一部分。

Below is a portion of the program iam attempting to modify.

  bExitFlag =
False

   执行
False = bExitFlag)  
'未按下停止按钮

     

      '获取"设置"中的输出集名称。工作表

      outSampleSetName = Worksheets(" Settings")。Range(" Sample_Set_Name")。offset(outSheetOffset)

     
如果 (0 = Len (修剪(outSampleSetName)))
然后退出Do            
'如果为空,则退出

     

      工作表(outputSheetName) )。选择                           
'选择输出表

      outRangeCell =" D" &安培;格式((outSheetOffset * samplesNeeded)+ 2)   
'实际数据的输出范围

     工作表(outputSheetName).Range(outRangeCell)。选择              
'启动输出单元格

     设置outRange =工作表(outputSheetName)。范围(outRangeCell)      
'在此单元格中开始数据输出

        

     "收集数据前提示用户"

      response1 = MsgBox("准备收集样本集的数据"& Str(outSheetOffset + 1)&":"& outSampleSetName&"'。"& vbCrLf& _

        "这应该采取大约"& Str(Int(samplesNeeded / sps))&"秒。"& vbCrLf& vbCrLf& _

        " Proceed?",vbYesNo + vbQuestion)

     
如果 response1<> ; vbYes
然后

      response2 = MsgBox("你可以返回上一个测量或结束程序。"& vbCrLf& vbCrLf&"你想要返回吗?",vbYesNo + vbQuestion)

     如果response2<> vbYes然后退出DoEsese outSheetOffset = outSheetOffset - 2

    

       结束如果        
'如果用户选择"否",则为"否"。按钮,然后退出此循环

     

     

        在以红色突出显示的行中,我让操作员选择是返回上一个测量还是结束程序。如果他们选择返回上一个测量值,则outSheetOffset
将重置为该位置。那部分工作正常。但是我希望程序返回到Do While循环的开头。你能帮我搞清楚怎么做吗?

        In the line highlighted in red, I am having the operator select whether to return to the previous measurement or end the program. If they choose to return to the previous measurement then the outSheetOffset is reset to that location. That part is working fine. However I would like the program to return to the beginning of the Do While loop. Can you help me figure out how to do that?

推荐答案

Rob,

这是Visual Studio Net中的VB论坛,有一个同样的VBA论坛

this is the forum for VB in Visual Studio Net, there is a likewise forum for VBA

http://social.msdn.microsoft.com/Forums/en-US/isvvba

这是你正在使用的VB。

That is the VB you are using.


这篇关于当用户中途停止循环时重新启动循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆