我現在想找到我的if/else語句錯誤我跑了一些小測試,看看我的變量都抱着值,它們只不過是我不斷收到零當我點擊提交按鈕時。如果聲明沒有給出正確答案ASP.NET
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles Pack_Weight.TextChanged
End Sub
Protected Sub Submit_Button_Click(sender As Object, e As EventArgs) Handles Submit_Button.Click
Dim PackageW, MemphisRate, SanFranRate As Double
'takes user input from the textbox and places it in the variable
PackageW = Pack_Weight.Text
'if user selects the dropbox and radiobutton list the selected combo should charge a varying bag fee
If Location.SelectedValue = "1" & ShippingList.SelectedValue = "1" Then
MemphisRate = 2.2 * PackageW
ElseIf Location.SelectedValue = "1" & ShippingList.SelectedValue = "2" Then
MemphisRate = 2.59 * PackageW
ElseIf Location.SelectedValue = "1" & ShippingList.SelectedValue = "3" Then
MemphisRate = 2.92 * PackageW
End If
'outputs the user selected combo to the total amount textbox
Total_Cost.Text = MemphisRate
If Location.SelectedValue = "2" & ShippingList.SelectedValue = "1" Then
SanFranRate = 2.2 * PackageW
ElseIf Location.SelectedValue = "2" & ShippingList.SelectedValue = "2" Then
SanFranRate = 2.59 * PackageW
ElseIf Location.SelectedValue = "2" & ShippingList.SelectedValue = "3" Then
SanFranRate = 2.92 * PackageW
End If
Total_Cost.Text = SanFranRate
End Sub
End Class
哪給你0?在對它們進行任何計算之前,總是將接收到的輸入解析/轉換爲數字類型。 – Thangadurai
這就是當我目前正在測試以試圖弄清楚,因爲現在一切都給零了,我不知道if語句中的哪個部分可以變爲零。 – AH5811