MainSub完成5项任务。目前,有几项任务是作为返回它们是否成功的函数编写的。我只想在前一个成功完成后继续执行下一个任务,否则运行workerThreadComplete。
有没有办法构建这个,以便MainSub更具可读性,特别是删除每行上的“If Not [] Then GoTo”片段?这样的事情应该如何构建?
Sub MainSub(params As Object) 'run by workerThread
Dim s As sessionData = CType(params, sessionData)
If Not verifyExcelResource(s) Then GoTo eexit
If Not launchAS400(s) Then GoTo eexit
If Not runLookup(s) Then GoTo eexit
If Not payeeProcessLoop(s) Then GoTo eexit
exportDoc(s)
workerThreadComplete
eexit:
workerThreadComplete
End Sub
答案 0 :(得分:1)
方式之一:
Sub MainSub(params As Object) 'run by workerThread
Dim s As sessionData = CType(params, sessionData)
If (verifyExcelResource(s) AndAlso
launchAS400(s) AndAlso
runLookup(s) AndAlso
payeeProcessLoop(s))
Then
exportDoc(s)
workerThreadComplete
End Sub