VBScript conditional short-circuiting workaround

后端 未结 9 2097
心在旅途
心在旅途 2021-02-19 05:15

I have a large classic ASP app that I have to maintain, and I repeatedly find myself thwarted by the lack of short-circuit evaluation capability. E.g., VBScript won\'t let you

9条回答
  •  天涯浪人
    2021-02-19 05:39

    I always used Select Case statements to short circuit logic in VB. Something like..

    Select Case True
    
    Case isNull(Rs("myField"))
    
        myField = 0
    
    Case (Rs("myField") <> 0)
    
        myField = Rs("myField")
    
    Case Else
    
        myField = -1        
    
    End Select
    

    My syntax may be off, been a while. If the first case pops, everything else is ignored.

提交回复
热议问题