vb.net - 如何不断地将 If 语句内容添加在一起

标签 vb.net

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/

相关文章:

c# - 为什么使用 System.Threading.Interlocked.Decrement 而不是 minus?

vb.net - 单击 ListView 子项并打开窗口

wpf - CallerMemberName 与 VB 的 INotifyPropertyChange 一起使用?

mysql - 如何使用按钮“下一个”和“上一个”从数据库读取数据

c# - 如何使用 C# 或 VB 读取 SSL 证书的序列号?

.net - Entity Framework - 保持数据库上下文打开与不断重新创建

c++ - 从 vb 调用非托管 c++ dll 中的函数

wpf - vb.Net:在BackgroundWorker中创建UI

firefox - 枚举 IE8 和 Firefox 中的选项卡

vb.net - c#和VB.NET的代码分析