View Single Post
  #5 (permalink)  
Old April 22nd, 2009, 05:34 AM
Tandy1000SL GW-BASIC Tandy1000SL GW-BASIC is offline
Authorized User
 
Join Date: Apr 2009
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Post

"For...Next" Loop looks like this.

Code:
 
Dim Counter
 
For Counter = 1 to 10
     MsgBox Counter
Next     'Counter
To [BREAK] out of the "For...Next" Loop, you will want to insert a Code Sequence. Most likely with some sort of User Input Sequence such as with the InputBox Statement.

Code:
 
Dim Counter
Dim strCounter
 
For Counter = 1 to 10
     MsgBox Counter
     strCounter = InputBox("?Do you want to Continue?")
          If strCounter = "" Then
               Counter = 11
          End If
Next     'Counter
A better method would be to use a MsgBox "?Do you want to Continue?" with the "VbYesNo" Constant; as well as, the "VbYes" and "VbNo" Constants in place of the InputBox Sequence; but, I'm not familiar enough with VBScript to write such a sequence at this time.

I am new to VBScript; thus, I only know how to use InputBox for User Inputs in VBScript Codes at this time.

With GW-BASIC, all you needed was a GOTO Statement to [BREAK] out of the "For...Next" Loops because all the Command Lines were numbered.

With GW-BASIC, you could also use the INKEY$ Statement to [BREAK] out of the "For...Next" Loop.

I haven't tested out my Input Sequence; thus, if you get a "Subscript Out Of Range" Error, you should change the Counter = 11 Command Line to Counter = 10.

Last edited by Tandy1000SL GW-BASIC; April 22nd, 2009 at 05:43 AM..
Reply With Quote