Search code examples
vbscriptcase-statement

VBScript Case statement query


I'm working on a legacy application and have no way of debugging the code. I'm programmatically updating a case statement based on the values selected in the application.

My question is - Is it possible to have a Case statement with ONLY a 'Case Else'? e.g.

        Select Case (test)
            Case Else
                test = "this is a test"
        End Select

Solution

  • Yes

    The vbscript documentation states that the case expresions are optional

    Select Case testexpression
       [Case expressionlist-n
          [statements-n]] . . .
       [Case Else
          [elsestatements-n]]
    End Select