Link to home
Start Free TrialLog in
Avatar of csho
cshoFlag for United States of America

asked on

Looping

This is a second part to a previously solved problem:

https://www.experts-exchange.com/questions/21391917/Looping-Shell-Urgent.html

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

Anyone?

Avatar of vinnyd79
vinnyd79

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
ASKER CERTIFIED SOLUTION
Avatar of vinnyd79
vinnyd79

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of csho

ASKER

Again, thank you.
Your welcome. Thanks for the points.