Looping

This is a second part to a previously solved problem:

http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_21391917.html

I now need to use the corrected syntax in a loop from 000001 to 10673 with the number format having 6 digits.

Anyone?

cshoAsked:
Who is Participating?
 
vinnyd79Commented:
In the above comment I am assuming that you will need to wait for each command to finish before going on to the next one. If not,you can use Shell Instead of ShellWait. Also,If the program launches a window you can replace vbNormalFocus with vbHide to not show it.
0
 
vinnyd79Commented:
Private Declare Function OpenProcess Lib "Kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function GetExitCodeProcess Lib "Kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
Private Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Long)
Const STILL_ACTIVE = &H103
Const PROCESS_QUERY_INFORMATION = &H400

Private Function ShellWait(PathName, Optional WindowStyle As VbAppWinStyle = vbNormalFocus) As Double
Dim hProcess As Long, RetVal As Long
    hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, Shell(PathName, WindowStyle))
    Do
        GetExitCodeProcess hProcess, RetVal
        DoEvents: Sleep 100
    Loop While RetVal = STILL_ACTIVE
End Function


Private Sub Command1_Click()
Dim x As Long
For x = 1 To 10673
    ShellWait Chr$(34) & "C:\Program Files\IrfanView\i_view32.exe" & Chr$(34) & " /multitif=(c:\sample\mtout\" & Format(x, "#000000") & ".tif,c:\sample\mt\" & Format(x, "#000000") & ".tif,C:\FAQ\FAQ.tif)", vbNormalFocus
Next x
End Sub
0
 
cshoAuthor Commented:
Again, thank you.
0
 
vinnyd79Commented:
Your welcome. Thanks for the points.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.