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
lstOutput.Text = Bill * (1 + if (Tip<1,Tip,Tip/100))
You used "if" which is used in an if...then statement, but i bet you meant iif, which is a function
lstOutput.Text = Bill * (1 + IIf (Tip<1,Tip,Tip/100))
just add that one extra "i" and you should be fine
Article explaining the difference between "IF" and "IIF()"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With