ption Explicit On
Option Strict On
Public Class MainForm
Private Function CalcResidential TotalDue() As Decimal
' calculates and returns the total due for a residential customer
' declare constants and variables
Const ResidentialProc essing As Decimal = 4.5D
Const ResidentialBasi c As Decimal = 30D
Const ResidentialPrem ium As Decimal = 5D
Dim premiumChannels As Decimal
Dim charge As Decimal
' residential customers do not have connections
connectionListB ox.SelectedInde x = 0
' get number of premium channels
premiumChannels = Convert.ToDecim al(premiumListB ox.SelectedItem )
' calculate total due
charge = ResidentialProc essing + ResidentialBasi c _
+ ResidentialPrem ium * premiumChannels
' return the total due
Return charge
End Function
Private Function CalcBusinessTot alDue() As Decimal
' calculates and returns the total due for a business customer
' declare constants and variables
Const BusinessProcess ing As Decimal = 16.5D
Const BusinessFirst10 Connections As Decimal = 80D
Const BusinessAdditio nalConnections As Decimal = 4D
Const BusinessPremium Channel As Decimal = 50D
Dim connections As Decimal
Dim premiumChannels As Decimal
Dim charge As Decimal
Dim businessBasic As Decimal
' get number of connections
connections = Convert.ToDecim al(connectionLi stBox.SelectedI tem)
' business customers must have at least one connection
If connections = 0 Then
MessageBox.Show ("The number of connections must be greater than 0.", _
"Cable Direct", MessageBoxButto ns.OK, MessageBoxIcon. Information)
Else
' get number of premium channels
premiumChannels = Convert.ToDecim al(premiumListB ox.SelectedItem )
' calculate the basic service
If connections <= 10D Then
businessBasic = BusinessFirst10 Connections
Else
businessBasic = BusinessFirst10 Connections _
+ (connections - 10D) * BusinessAdditio nalConnections
End If
' calculate the total due
charge = BusinessProcess ing + businessBasic _
+ BusinessPremium Channel * premiumChannels
End If
' return the total due
Return charge
End Function
Private Sub ClearTotalDue(B yVal sender As Object, ByVal e As System.EventArg s) _
Handles businessRadioBu tton.Click, residentialRadi oButton.Click, _
premiumListBox. SelectedValueCh anged, connectionListB ox.SelectedValu eChanged
totalDueLabel.T ext = String.Empty
End Sub
Private Sub MainForm_Load(B yVal sender As Object, ByVal e As System.EventArg s) Handles Me.Load
' fills the list boxes with values, then selects the first value
For premiumChannel As Integer = 0 To 20
premiumListBox. Items.Add(premi umChannel.ToStr ing)
Next premiumChannel
For connections As Integer = 0 To 100
connectionListB ox.Items.Add(co nnections.ToStr ing)
Next connections
premiumListBox. SelectedIndex = 0
connectionListB ox.SelectedInde x = 0
End Sub
Private Sub calcButton_Clic k(ByVal sender As Object, ByVal e As System.EventArg s) Handles calcButton.Clic k
' calculates and displays a customer's bill
Dim totalDue As Decimal
' call appropriate function to calculate the total due
' display the total due
totalDueLabel.T ext = totalDue.ToStri ng("C2")
End Sub
Private Sub exitButton_Clic k(ByVal sender As Object, ByVal e As System.EventArg s) Handles exitButton.Clic k
Me.Close()
End Sub
End Class
OK so I feel stupid ..jere I have written all of this code yet I have forgotten how to call a function to get this to calculate
Someone please remind me
Option Strict On
Public Class MainForm
Private Function CalcResidential TotalDue() As Decimal
' calculates and returns the total due for a residential customer
' declare constants and variables
Const ResidentialProc essing As Decimal = 4.5D
Const ResidentialBasi c As Decimal = 30D
Const ResidentialPrem ium As Decimal = 5D
Dim premiumChannels As Decimal
Dim charge As Decimal
' residential customers do not have connections
connectionListB ox.SelectedInde x = 0
' get number of premium channels
premiumChannels = Convert.ToDecim al(premiumListB ox.SelectedItem )
' calculate total due
charge = ResidentialProc essing + ResidentialBasi c _
+ ResidentialPrem ium * premiumChannels
' return the total due
Return charge
End Function
Private Function CalcBusinessTot alDue() As Decimal
' calculates and returns the total due for a business customer
' declare constants and variables
Const BusinessProcess ing As Decimal = 16.5D
Const BusinessFirst10 Connections As Decimal = 80D
Const BusinessAdditio nalConnections As Decimal = 4D
Const BusinessPremium Channel As Decimal = 50D
Dim connections As Decimal
Dim premiumChannels As Decimal
Dim charge As Decimal
Dim businessBasic As Decimal
' get number of connections
connections = Convert.ToDecim al(connectionLi stBox.SelectedI tem)
' business customers must have at least one connection
If connections = 0 Then
MessageBox.Show ("The number of connections must be greater than 0.", _
"Cable Direct", MessageBoxButto ns.OK, MessageBoxIcon. Information)
Else
' get number of premium channels
premiumChannels = Convert.ToDecim al(premiumListB ox.SelectedItem )
' calculate the basic service
If connections <= 10D Then
businessBasic = BusinessFirst10 Connections
Else
businessBasic = BusinessFirst10 Connections _
+ (connections - 10D) * BusinessAdditio nalConnections
End If
' calculate the total due
charge = BusinessProcess ing + businessBasic _
+ BusinessPremium Channel * premiumChannels
End If
' return the total due
Return charge
End Function
Private Sub ClearTotalDue(B yVal sender As Object, ByVal e As System.EventArg s) _
Handles businessRadioBu tton.Click, residentialRadi oButton.Click, _
premiumListBox. SelectedValueCh anged, connectionListB ox.SelectedValu eChanged
totalDueLabel.T ext = String.Empty
End Sub
Private Sub MainForm_Load(B yVal sender As Object, ByVal e As System.EventArg s) Handles Me.Load
' fills the list boxes with values, then selects the first value
For premiumChannel As Integer = 0 To 20
premiumListBox. Items.Add(premi umChannel.ToStr ing)
Next premiumChannel
For connections As Integer = 0 To 100
connectionListB ox.Items.Add(co nnections.ToStr ing)
Next connections
premiumListBox. SelectedIndex = 0
connectionListB ox.SelectedInde x = 0
End Sub
Private Sub calcButton_Clic k(ByVal sender As Object, ByVal e As System.EventArg s) Handles calcButton.Clic k
' calculates and displays a customer's bill
Dim totalDue As Decimal
' call appropriate function to calculate the total due
' display the total due
totalDueLabel.T ext = totalDue.ToStri ng("C2")
End Sub
Private Sub exitButton_Clic k(ByVal sender As Object, ByVal e As System.EventArg s) Handles exitButton.Clic k
Me.Close()
End Sub
End Class
OK so I feel stupid ..jere I have written all of this code yet I have forgotten how to call a function to get this to calculate
Someone please remind me
Comment