Currently working on an application with the following guidelines:
The application is supposed to feature a program that calculates and displays a customer's bill using the interface and figures found here: http://books.google.com/books?id=jGvseZN0g7gC&pg=PA468&lpg=PA468&dq=cable+direct+visual+basic&source=bl&ots=z0KhRX9BGS&sig=8zejHyLyd6Vb8kTVuJIrnsM1p4k&hl=en&ei=fLOHTev5EZOXtwf_zYzTBA&sa=X&oi=book_result&ct=result&resnum=3&ved=0CC4Q6AEwAg#v=onepage&q&f=false
In addition, the following features are required:
- The premium channels ListBox (channelsListBox) has the following selection: 1, 2, 3, 4, 5, 6. The default selection is 1 when you launch the application
- Business customers will fill the number of additional connections in a TextBox (connectionsTextBox), which should be empty when you launch the application
- Please create a CalDue function procedure to calculate total due for both types of customers.
- Create a ClearLabels Sub Procedure to handle four objects and their associated events.
- These four objects and events are: channelsListBox.Textchanged, connectionsTextBox.TextChanged, businessRadioButton.Click, and residentialRadioButton.Click
- When the ClearLabels sub procedure is invoked, it should clear the totalDueLabel to display an empty string.
The problem that I am currently having is that the program does not calculate the correct total amounts for the residential and business customers. I believe it has something to do with the premium channels list and connections text box. Any assistance or advice would be greatly appreciated. Here is the code I have to this point:
Option Explicit On Option Strict On Option Infer Off Public Class Form1 Private Sub exitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles exitButton.Click Me.Close() End Sub Private Function CalcResidentialTotalDue(ByVal premiumChannels As Integer) As Decimal Const ResidentialProcessing As Decimal = 4.5D Const ResidentialBasic As Decimal = 30D Const ResidentialPremium As Decimal = 5D Return ResidentialProcessing + ResidentialBasic + ResidentialPremium * premiumChannels End Function Private Function CalcBusinessTotalDue(ByVal premiumChannels As Integer, _ ByVal connections As Integer) As Decimal Const BusinessProcessing As Decimal = 16.5D Const BusinessFirst10Connections As Decimal = 80D Const BusinessAdditionalConnections As Decimal = 4D Const BusinessPremiumChannel As Decimal = 50D Dim businessBasic As Decimal If connections <= 10 Then businessBasic = BusinessFirst10Connections Else businessBasic = BusinessFirst10Connections _ + ((connections - 10) * BusinessAdditionalConnections) End If Return BusinessProcessing + businessBasic + BusinessPremiumChannel * premiumChannels End Function Private Sub ClearLabels(ByVal sender As Object, ByVal e As System.EventArgs) _ Handles businessRadioButton.Click, residentialRadioButton.Click, _ channelsListBox.TextChanged, connectionsTextBox.TextChanged totaldueLabel.Text = String.Empty End Sub Private Sub Form1_Load(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles Me.Load channelsListBox.Items.Add("1") channelsListBox.Items.Add("2") channelsListBox.Items.Add("3") channelsListBox.Items.Add("4") channelsListBox.Items.Add("5") channelsListBox.Items.Add("6") End Sub Private Sub CalDue(ByVal sender As Object, ByVal e As System.EventArgs) Handles caldueButton.Click Dim premiumChannels As Integer = channelsListBox.SelectedIndex Dim Connections As Integer Dim totalDue As Decimal = 0 If residentialRadioButton.Checked Then totalDue = CalcResidentialTotalDue(premiumChannels) Else totalDue = CalcBusinessTotalDue(premiumChannels, Connections) End If totaldueLabel.Text = totalDue.ToString("C2") End Sub End Class