Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Looping

Posted on 2005-04-17
4
Medium Priority
?
222 Views
Last Modified: 2010-05-02
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?

0
Comment
Question by:csho
  • 3
4 Comments
 
LVL 28

Expert Comment

by:vinnyd79
ID: 13801616
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
 
LVL 28

Accepted Solution

by:
vinnyd79 earned 2000 total points
ID: 13801633
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
 

Author Comment

by:csho
ID: 13801674
Again, thank you.
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 13801689
Your welcome. Thanks for the points.
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question