View Single Post
  #10 (permalink)  
Old May 1st, 2009, 05:15 AM
Old Pedant Old Pedant is offline
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

It's truly amazing how badly you manage to misread documentation. Either that, or the book you are learning from needs to thrown in the trash. I've never seen that book; I learned VBScript from reading Microsoft's documentation.

Yes, you *CAN* use an ELSE as the last "catch all" condition in an "IF...ELSEIF...ELSEIF...ELSE...END IF" sequence. But you do *NOT* HAVE TO! It *IS* optional.

I'm going to bet you won't believe me without proof, so try this VBS file, yourself:
Code:
MsgBox "First iteration..."

For i = 1 To 4
    If i > 3 Then
        MsgBox "i is " & i & " which is greater than 3"
    Elseif i > 2 Then
        MsgBox "i is " & i & " which is greater than 2"
    Else
        MsgBox "is is " & i
    End If
Next

MsgBox "Now starting the second iteration..."

For i = 1 To 4
    If i > 3 Then
        MsgBox "i is " & i & " which is greater than 3"
    Elseif i > 2 Then
        MsgBox "i is " & i & " which is greater than 2"
    End If
Next
Oh...and I don't really care what GW-BASIC does or does not or did or did not accept. I wrote 4 different BASIC interpreters during my career, and every one of them did *something* differently than VBScript does and they are all irrelevant today.
Reply With Quote