basicServiceFee 允许 10 个免费连接,价格为 80 美元
只要连接数 > 10,每个附加连接的费用为 4 美元加上基本连接
如何添加 4 美元费用并在选择connectionsListBox 中的每个号码时继续添加该费用。
我的代码在connectionsListBox 上添加了第一个4 美元的费用,然后在11 点后停止。我怎样才能让 12 变成另外 4 美元,13 变成另外 4 美元
这是我的代码:
Private Function businessTotalCharges(ByVal processingFee As Double, ByVal basicServiceFee As Double,
ByVal premiumChannelFee As Double, ByVal connections As Double) As Double
Dim total As Double
Dim perchannel As Double
Dim totalChannelFee As Double
Dim connectionsPrice As Double
Dim perConnection As Double
processingFee = 16.5
basicServiceFee = 80
perchannel = CDbl(premiumListBox.SelectedItem) * 50
connections = CDbl(connectionsListBox.SelectedItem)
premiumChannelFee = (CDbl(premiumListBox.SelectedItem))
If connections > 10 Then
connectionsPrice = basicServiceFee + 4
End If
If connections <= 10 Then
connectionsPrice = basicServiceFee
End If
If premiumChannelFee > 0 Then
totalChannelFee = perchannel + connectionsPrice
End If
total = totalChannelFee + processingFee
totalLabel.Text = total.ToString("C2")
Return total
End Function
Private Sub calcButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles calcButton.Click
Dim procFee As Double
Dim basicFee As Double
Dim channelFee As Double
Dim connectionNum As Double
If residentialRadioButton.Checked = True Then
Call residentialTotalCharges(procFee, basicFee, channelFee)
End If
If businessRadioButton.Checked = True Then
Call businessTotalCharges(procFee, basicFee, channelFee, connectionNum)
End If
End Sub
End Class
最佳答案
简单的数学:
connectionsPrice = basicServiceFee + 4 * (connections - 10)
关于vb.net - 如何不断地将 If 语句内容添加在一起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9138765/