can't seem to get program to stop when i need it to
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: can't seem to get program to stop when i need it to

  1. #1
    Join Date
    Aug 2014
    Posts
    1

    can't seem to get program to stop when i need it to

    i have been trying to make a vbs script that re names files have them named like bg1 bg2 bg3 bg4... i have the program doing this but for some reason the program wont stop i need some help with this.

    Set WshShell = WScript.CreateObject("WScript.Shell")
    strtext = inputbox("Da file nme plz :3 :")
    f = inputbox("How much files are there:")

    WshShell.SendKeys "{RIGHT}"
    WshShell.SendKeys "{LEFT}"
    Dim a
    a = inputbox("Number to start at:")
    do
    a=a+1

    WshShell.SendKeys "{F2}"
    WshShell.SendKeys (strtext & a)
    WshShell.SendKeys "{TAB}"
    loop while a<f
    WshShell.SendKeys "{ENTER}"
    inputbox("done :3")

  2. #2
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,982

    Re: can't seem to get program to stop when i need it to

    Your loop is wrong:
    Code:
    Do While i>10
       some code
     Loop
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    4,838

    Re: can't seem to get program to stop when i need it to

    Loop looks ok to me, or sort of anyway. The while part probably should be on the Do rather than the loop so that it does not execute it a>f on the first pass
    It assigns a starting value to f and to a before the loop
    A is incremented inside the loop
    loop condition is while a<f which at some point would be false and end the loop assuming of course a number is actually entered in the input box for f otherwise it could run forever

    That said if the goal is to rename some files that is not the way to go about it.
    You may want to look into the FSO and how to use it to rename a file and forget about using SendKeys
    Always use [code][/code] tags when posting code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center