0

我写了一些代码来找出 3 个变量中最低的然后显示它,但我得到“'If' 运算符需要两个或三个操作数”。我不确定问题是什么,任何帮助将不胜感激。

<%      

            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%>

谢谢刘易斯

4

2 回答 2

3

这是因为您if在每个现有if语句中都有另一个...

if HP_RegularPayment < LPC_RegularPayment and **if** HP_RegularPayment < PCP_RegularPayment then

VB.NET 有一个称为运算符的运算符If,它接受两个或三个参数,如果第一个是Nothing,则返回第二个参数。

删除它,这使得线......

if HP_RegularPayment < LPC_RegularPayment and HP_RegularPayment < PCP_RegularPayment then

我也同意@IrishChieftain 在他的评论中,你应该真正分开你的代码和标记。

于 2012-06-26T15:54:30.653 回答
2

代替

if HP_RegularPayment < LPC_RegularPayment and if HP_RegularPayment < PCP_RegularPayment then 

采用

if HP_RegularPayment < LPC_RegularPayment and HP_RegularPayment < PCP_RegularPayment then 
于 2012-06-26T15:53:28.747 回答