-
I need a way to run subs/functions one after the other BUT make each wait untill the previous is finished.
Example:
private sub ProccessALL ()
call ProccessFile
call showinfo ' should run AFTER "ProccessFile" finished
call MakeAll ' should run AFTER "showinfo" finished
end sub
-
What are you talking about? Your code will do exactly what you want it to do.
-
Well, that's what I thought, but from some reason, it doesn't ... , it just goes through all of them in a row and the last one is finished before the first one is done..
-
What are you doing in these 3 functions?
-
Return value
May be you can return a value from each function
- ProccessFile
- showinfo
- MakeAll
So that you can base on the return value to determine whether the program should continue with the next function or skip the next coming up function.
Let assume each function will return a Boolean value either True or False. (True = Succesfful, False = Fail)
Code:
If ProcessFile Then
If showinfo Then
If MakeAll Then
MsgBox "All the function is completed!.", vbExclamation
Else
MsgBox "MakeAll function does not completed!.", vbExclamation
End If
Else
MsgBox "showinfo function does not completed!.", vbExclamation
End If
Else
MsgBox "ProcessFile function does not completed!.", vbExclamation
End If
-
I can't see the problem either, that should work totally in the order you have put them.
You could put a breakpoint on the first and then press F8 so you can follow in which order all executes
-
Well, the thing it does is parsing a text file, and putting all the information into a dictionary object, and than it makes folders (according to the keys in the dictionary object), the last step is making text files under each folder (in each file there is part of the original file).
Chris gave a nice way to do it, but I will be more than happy to get some other ideas as well :-)
Thank you every body.
-
Another possible thing that can cause this is if you enable a timercontrol which inhibits it's code wherever it you got a doevents... Have you tried to use F8 as i said?
-
I'm sorry to disagree with some of you folks, but the code as shown in the original post will ALWAYS run one after the other, and you don't need to turn them into functions that return something in order to ensure that. What CAN happen however is that ProcessFile calls some routine or causes some other routine to be called, and that routine then calls MakeAll, which may make it seem like the routines are running out of order. Even in that case however, when ProcessFile is done, showinfo will run and then MakeAll (again) unless there is an "End" someplace inbetween. To find out what's going on, set a breakpoint in MakeAll and when that routine is reached, examine the call tree to see how it got there.