How to do a single line If statement in VBScript for Classic-ASP?

后端 未结 5 1794
萌比男神i
萌比男神i 2020-12-14 06:41

The \"single line if statement\" exists in C# and VB.NET as in many other programming and script languages in the following format

lunchLocation = (dayOfTheW         


        
5条回答
  •  余生分开走
    2020-12-14 07:28

    VBScript does not have any ternary operator.
    A close solution in a single line and without using a user defined function, pure VBScript:

    If dayOfTheWeek = "Tuesday" Then lunchLocation = "Fuddruckers" Else lunchLocation = "Food Court"
    

    BTW, you can use JScript in Classic ASP if ternary opertor is so important to you.

提交回复
热议问题