Welcome !
         

 Error: Redefined Name

Author Message
Lucid Liam

  • Total Posts : 2
  • Scores: 0
  • Reward points : 0
  • Joined: 12/9/2016
  • Status: offline
Error: Redefined Name Friday, December 09, 2016 9:29 AM (permalink)
0
I am currently coding a vbs script for the first time. When I try to run it, I get this.
Error: Redefined Name
Line:14
Char:5
Here is my code:
Set wshShell = wscript.CreateObject("WScript.Shell")dodim max,minmax=900000min=420000
Dim RNDMRandomizeRNDM=((max)*Rnd+min)
wscript.sleep (RNDM)wshshell.sendkeys "{^}"wscript.sleep (RNDM)dim max,minmax=900000min=420000
Dim RNDMRandomizeRNDM=((max)*Rnd+min)
wshshell.sendkeys "{%}"wscript.sleep (RNDM)dim max,minmax=900000min=420000
Dim RNDMRandomizeRNDM=((max)*Rnd+min)
wshshell.sendkeys "{*}"dim max,minmax=900000min=420000
Dim RNDMRandomizeRNDM=((max)*Rnd+min)
wscript.sleep (RNDM)wshshell.sendkeys "{@}"dim max,minmax=900000min=420000
Dim RNDMRandomizeRNDM=((max)*Rnd+min)
wscript.sleep (RNDM)wshshell.sendkeys "{/}"dim max,minmax=900000min=420000
Dim RNDMRandomizeRNDM=((max)*Rnd+min)
wscript.sleep (RNDM)loop

 
#1
    59cobalt

    • Total Posts : 2608
    • Scores: 253
    • Reward points : 0
    • Joined: 7/17/2011
    • Status: offline
    Re:Error: Redefined Name Friday, December 09, 2016 9:37 AM (permalink)
    0
    You can't Dim the same variable multiple times in VBScript (unless you do the definition in different scopes). Dim it once, then just use it.

    Also, whenever you're using SendKeys in your code you should pause and seriously re-evaluate your approach. Chances are pretty high that you took a wrong turn somewhere.
     
    #2
      Lucid Liam

      • Total Posts : 2
      • Scores: 0
      • Reward points : 0
      • Joined: 12/9/2016
      • Status: offline
      Re:Error: Redefined Name Friday, December 09, 2016 11:08 AM (permalink)
      0
      so does this mean that the random number will be the same for each sleep? or will i just need to get rid of the dim and it will be different each time?
       
      #3
        59cobalt

        • Total Posts : 2608
        • Scores: 253
        • Reward points : 0
        • Joined: 7/17/2011
        • Status: offline
        Re:Error: Redefined Name Friday, December 09, 2016 3:59 PM (permalink)
        0
        Get rid of the additional Dims. Also, call Randomize just once at the beginning. The Rnd function does the rest.
         
        #4
          Online Bookmarks Sharing: Share/Bookmark

          Jump to:

          Current active users

          There are 0 members and 1 guests.

          Icon Legend and Permission

          • New Messages
          • No New Messages
          • Hot Topic w/ New Messages
          • Hot Topic w/o New Messages
          • Locked w/ New Messages
          • Locked w/o New Messages
          • Read Message
          • Post New Thread
          • Reply to message
          • Post New Poll
          • Submit Vote
          • Post reward post
          • Delete my own posts
          • Delete my own threads
          • Rate post

          2000-2017 ASPPlayground.NET Forum Version 3.9