我已经编写了一些代码来查找3个变量中的最低值然后显示它但是我得到“'如果'运算符需要两个或三个操作数。”我不确定这个问题是什么,我们将不胜感激。
<%
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%>
谢谢刘易斯
答案 0 :(得分:3)
这是因为您在现有的if
声明中都有另一个if
...
if HP_RegularPayment < LPC_RegularPayment and **if** HP_RegularPayment < PCP_RegularPayment then
名为If
的{p> VB.NET has an operator需要两个或三个参数,如果第一个参数为Nothing
,则返回第二个参数。
删除它,这就行......
if HP_RegularPayment < LPC_RegularPayment and HP_RegularPayment < PCP_RegularPayment then
我也同意@IrishChieftain的评论,你应该把你的代码和标记分开。
答案 1 :(得分:2)
而不是
if HP_RegularPayment < LPC_RegularPayment and if HP_RegularPayment < PCP_RegularPayment then
使用
if HP_RegularPayment < LPC_RegularPayment and HP_RegularPayment < PCP_RegularPayment then