Reputation: 2145
I have wrote some code to find out of 3 variables witch is the lowest then display it but i am getting "'If' operator requires either two or three operands." and i am unsure as to what the issue is any help would be greatly appreciated.
<%
dim HP_RegularPayment As Integer = HP_RegularPayment
dim LPC_RegularPayment As Integer = LPC_RegularPayment
dim PCP_RegularPayment As Integer = PCP_RegularPayment
if HP_RegularPayment < LPC_RegularPayment and if HP_RegularPayment < PCP_RegularPayment then
%>
<div id="detailsprice" style="height:70px; padding-top:5px;">
£<% if DiscountPrice.Text = "" then
Response.Write(DiscountPrice.Text)
else
Response.Write(Price.Text)
end if
%><br /> <span style="font-size:12px;">Or £<%Response.Write(HP_RegularPayment) %> Per Month With HP Finance</span> </div> <%
else if LPC_RegularPayment < HP_RegularPayment and if LPC_RegularPayment < PCP_RegularPayment then
%>
<div id="detailsprice" style="height:70px; padding-top:5px;">
£<% if DiscountPrice.Text = "" then
Response.Write(DiscountPrice.Text)
else
Response.Write(Price.Text)
end if
%><br /> <span style="font-size:12px;">Or £<%Response.Write(LPC_RegularPayment) %>
Per Month With LP Finance</span> </div> <%
else if PCP_RegularPayment < HP_RegularPayment and if PCP_RegularPayment < LPC_RegularPayment then
%>
<div id="detailsprice" style="height:70px; padding-top:5px;">
£<% if DiscountPrice.Text = "" then
Response.Write(DiscountPrice.Text)
else
Response.Write(Price.Text)
end if
%><br /> <span style="font-size:12px;">Or £<%Response.Write(PCP_RegularPayment) %> Per Month With PCP Finance</span> </div> <%
else%>
<div id="detailsprice">
£<% if DiscountPrice.Text = "" then
Response.Write(DiscountPrice.Text)
else
Response.Write(Price.Text)
end if
end if%>
Thanks Lewis
Upvotes: 0
Views: 2844
Reputation: 19953
It's because you've got another if
within each of the existing if
statement...
if HP_RegularPayment < LPC_RegularPayment and **if** HP_RegularPayment < PCP_RegularPayment then
VB.NET has an operator called If
that takes two or three parameters, and if the first is Nothing
, it return the second parameter.
Remove it, which makes the line...
if HP_RegularPayment < LPC_RegularPayment and HP_RegularPayment < PCP_RegularPayment then
I would also agree with @IrishChieftain in his comment, that you should really separate your code and mark-up.
Upvotes: 3
Reputation: 51494
instead of
if HP_RegularPayment < LPC_RegularPayment and if HP_RegularPayment < PCP_RegularPayment then
use
if HP_RegularPayment < LPC_RegularPayment and HP_RegularPayment < PCP_RegularPayment then
Upvotes: 2