Or versus OrElse

前端 未结 8 1663
感情败类
感情败类 2020-11-27 04:33

What\'s the difference between or and OrElse?

if temp is dbnull.value or temp = 0

produces the error:

8条回答
  •  面向向阳花
    2020-11-27 04:55

    OrElse evaluate first expression then if its true it will proceed to the statement while OR evaluates two expressions before it will proceed to their statement.

    Example:

    Textbox1.Text= 4
    
    Textbox2.Text= ""
    

    Using OrElse

      If TextBox1.Text > 2 OrElse TextBox2.Text > 3 Then
          MsgBox("True")
      End If
    

    Result is: TRUE


    Using OR

     If TextBox1.Text > 2 Or TextBox2.Text > 3 Then
    
                MsgBox("True")
      End If
    

    Result is: Error cannot convert string to double.

提交回复
热议问题