I am new to development and am receiving the error ‘Expression Expected’ when I attempt to compile the code below. What am I doing wrong?
Public Class Form1 Private Sub btnCompute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCompute.Click Dim Occupation As String = CStr(txtOccupation.Text) Dim Bill As Double = CDbl(txtBill.Text) Dim Tip As Double = CDbl(txtTip.Text) lstOutput.Text = Bill * (1 + if (Tip<1,Tip,Tip/100)) End Sub End Class
I’m guessing the exception is being thrown on on the last line
You used ‘if’ which is used in an if…then statement, but i bet you meant iif, which is a function
just add that one extra ‘i’ and you should be fine
Article explaining the difference between ‘IF’ and ‘IIF()’