2012-06-26 124 views
0

我已經寫了一些代碼來找出3個變量女巫是最低的然後顯示它,但我得到''如果'操作符需要兩個或三個操作數。 「我不確定這個問題是什麼幫助將不勝感激。asp.net'如果'操作員需要兩個或三個操作數

<%  

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

感謝劉易斯

+1

您需要將您的代碼與標記分開。 – IrishChieftain

+0

你的權利,我應該但我沒有時間讓代碼優勢這只是一個quck和骯髒的構建。 –

回答

3

這是因爲你已經有了另一if內每個現有if語句...

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

VB.NET has an operator稱爲If,它有兩個或三個參數,以及如果所述第一是Nothing,將其返回第二個參數。

刪除它,這使該行...

if HP_RegularPayment < LPC_RegularPayment and HP_RegularPayment < PCP_RegularPayment then 

我也將與@IrishChieftain在他的評論表示贊同,那你真的應該分開你的代碼和標記。

2

,而不是

if HP_RegularPayment < LPC_RegularPayment and if HP_RegularPayment < PCP_RegularPayment then 

使用

if HP_RegularPayment < LPC_RegularPayment and HP_RegularPayment < PCP_RegularPayment then