Select Case True

后端 未结 9 1807
失恋的感觉
失恋的感觉 2020-11-27 07:08

Apparently this used to be a way in VB6 and VBA to short circuit and execute the first true case:

Select Case True
End Select

Is this still

9条回答
  •  失恋的感觉
    2020-11-27 07:32

    I'm not sure how this construct offers any advantages over the following:

    If testVariable < 0 Then
         Console.Write("You must supply a positive value.")
    ElseIf testVariable > 10 Then
         Console.Write("Please enter a number less than 10.")
    Else
         Call DoWork(testVariable)
    End If
    

    The above structure is short-circuiting, and I don't have to try to work out what it does as it's a standard construct.

提交回复
热议问题