View Single Post
  #1  
Old 02-15-2018, 12:31 PM
djvj djvj is offline
Registered User
 
Join Date: Oct 2011
Posts: 13
Why doesn't this For loop work?

Trying to automate a simple login process before I expand it to work on multiple devices that have different prompts, but I keep getting an Unexpected 'Next' error when it's ran and not sure why:

Code:
	For x = 0 To 2	' Loop this code 2 times (once for username, and again for password)
		result = crt.screen.waitforstrings ("ACS5.5 username:", "ACS5.5 password:", "password:", 5)	' wait 5 seconds for each try
		Select Case result
			Case 0
				msgbox "timeout occurred"
			Case 1
				crt.Screen.Send usr & VbCr	' Send your username followed by a carriage return
			Case 2
				crt.Screen.Send pw & VbCr	' Send your password followed by a carriage return
			Case 3
				crt.Screen.Send pw & VbCr	' Send your password followed by a carriage return
		Crt.Sleep 1000	' wait 1 second
	Next
The error might be obvious but not used to coding in VBS.
Reply With Quote