return 0
return 0

Reputation: 4366

How to define an empty select case statement in vbscript

If I have the following select cases:

Select Case var
    Case 1
        doA()
    Case 2
        doB()
    Case 3
        'empty
End select

What impact does this empty select case have? Is there an official/legit way to define an empty select case?

Upvotes: 1

Views: 1570

Answers (2)

Ekkehard.Horner
Ekkehard.Horner

Reputation: 38755

Having an empty Case (marked by a suitable comment) is the correct way to deal with cases like:

Select Case DayOfWeek
  Case Sat
    doSaturday
  Case Sun
    ' nothing to do for sundays
  Case Else
    doWorkingDay
End Select

Here, omitting the Sun Case would be an error.

Upvotes: 4

Matt Ball
Matt Ball

Reputation: 359936

Why wouldn't you omit that case entirely?

Select Case var
    Case 1
        doA()
    Case 2
        doB()
End select

Upvotes: 2

Related Questions