Skip to content

If + ElseIf

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #188252
    jekar
    Member

    GUYZ , I GOT A CODE SAYING :

    If Operator = “+” Then

    Result = Operand1 + Operand2

    ElseIf Operator = “-” Then

    Result = Operand1 – Operand2

    End If

    SO MY QUESTION IZ CAN I SAY :

    If Operator = “+” Then

    Result = Operand1 + Operand2

    If Operator = “-” Then

    Result = Operand1 – Operand2

    End If

    #188255
    Admin
    Administrator

    no, but you could make it say

    If Operator = "+" Then

    Result = Operand1 + Operand2

    End If 'note how you closed this If tag first

    If Operator = "-" Then 'and then this one starts a new If tag

    Result = Operand1 - Operand2

    End If
    #188254

    ofcause you can do that but nobody codes like that.

    the elseif exist for the reason if the first if is true the elseif will not be validated

    when there are alot of if and elseif we use select case

    #188253
    Departure
    Member

    assuming that – and + are the only two variables you could do it like this

    If Operator = “+” Then
    Result = Operand1 + Operand2
    Else
    Result = Operand1 – Operand2
    End If

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.