I'm creating an application where a user creates a cable bill. The application calculates the bill based on whether the customer is a residential or business customer. I've finished the interface and all of the calculations. However, the assignment is to use one or more sub or function procedures. I have several sub procedures but I don't have any function procedures and I'm not sure how to include one in my program without messing up what I've created. Any advice would be greatly appreciated. Thanks! Here's my code:
'Project Name: Tammy Seilheimer
'Project Purpose: This project calculates a customer's bill for cable services
'Created By: Tammy Seilheimer
[code=vbnet]
Option Explicit On
Public Class Form1
Private Sub residentialButt on_CheckedChang ed(ByVal sender As Object, ByVal e As System.EventArg s) Handles residentialbutt on.CheckedChang ed
connectionstext box.Visible = False
connectionsquan titytextbox.Vis ible = False
TextBox4.Visibl e = False
Label7.Visible = False
Label8.Visible = False
End Sub
Private Sub businessbutton_ checkedchanged( ByVal sender As Object, ByVal e As System.EventArg s) Handles businessbutton. CheckedChanged
connectionstext box.Visible = True
connectionsquan titytextbox.Vis ible = True
TextBox4.Visibl e = True
Label7.Visible = True
Label8.Visible = True
End Sub
Private Sub calculatebutton _Click(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles calculatebutton .Click
If residentialbutt on.Checked Then
Dim channelprice As Decimal
Dim residentialnumb erofchannels As Integer
Dim residentialchan neltotalprice As Decimal
Dim residentialamou ntdue As Decimal
Dim processingfee As Decimal
Dim basicfee As Decimal
Dim isconverted As Boolean
Dim isconverted2 As Boolean
Dim isconverted3 As Boolean
Dim isconverted4 As Boolean
isconverted = Integer.TryPars e(channelpricet extbox.Text, channelprice)
isconverted2 = Integer.TryPars e(processingtex tbox.Text, processingfee)
isconverted3 = Integer.TryPars e(basicfeetextb ox.Text, basicfee)
isconverted4 = Integer.TryPars e(premiumquanti tytextbox.Text, residentialnumb erofchannels)
'connectionstex tbox.Visible = False
'connectionsqua ntitytextbox.Vi sible = False
' TextBox4.Visibl e = False
'Label7.Visible = False
'Label8.Visible = False
If isconverted4 = True Then
processingfee = 4.5
basicfee = 30
channelprice = 5
premiumquantity textbox.Text = residentialnumb erofchannels
channelpricetex tbox.Text = channelprice.To String("C2")
residentialchan neltotalprice = (residentialnum berofchannels * channelprice)
channeltextbox. Text = residentialchan neltotalprice.T oString("C2")
processingtextb ox.Text = processingfee.T oString("C2")
basicfeetextbox .Text = basicfee.ToStri ng("C2")
residentialamou ntdue = (processingfee + basicfee + residentialchan neltotalprice)
amountduetextbo x.Text = residentialamou ntdue.ToString( "C2")
End If
End If
If businessbutton. Checked Then
Dim businessnumbero fchannels As Integer
Dim businessnumbero fconnections As Integer
Dim businesschannel totalprice As Decimal
Dim businessconnect ionstotalprice As Decimal
Dim businessamountd ue As Decimal
Dim channelprice As Decimal
Dim isconverted5 As Boolean
Dim isconverted6 As Boolean
Dim processingfee As Decimal
Dim basicfee As Decimal
Dim connectionprice As Decimal
isconverted5 = Integer.TryPars e(connectionsqu antitytextbox.T ext, businessnumbero fconnections)
isconverted6 = Integer.TryPars e(premiumquanti tytextbox.Text, businessnumbero fchannels)
If isconverted5 = True Then
processingfee = 16.5
basicfee = 80
channelprice = 50
connectionprice = 4
businessconnect ionstotalprice = businessnumbero fconnections * 4
businessnumbero fconnections = connectionsquan titytextbox.Tex t
channelpricetex tbox.Text = channelprice.To String("C2")
connectionstext box.Text = businessconnect ionstotalprice. ToString("C2")
TextBox4.Text = connectionprice .ToString("C2")
processingtextb ox.Text = processingfee.T oString("C2")
basicfeetextbox .Text = basicfee.ToStri ng("C2")
businesschannel totalprice = businessnumbero fchannels * 50
channeltextbox. Text = businesschannel totalprice.ToSt ring("C2")
businessnumbero fchannels = premiumquantity textbox.Text
businessamountd ue = (businesschanne ltotalprice + processingfee + basicfee + businessconnect ionstotalprice)
amountduetextbo x.Text = businessamountd ue.ToString("C2 ")
End If
End If
End Sub
Private Sub exitbutton_Clic k(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles Exitbutton.Clic k
Me.Close()
End Sub
Private Sub clearbutton_Cli ck(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles clearbutton.Cli ck
processingtextb ox.Text = String.Empty
basicfeetextbox .Text = String.Empty
connectionsquan titytextbox.Tex t = String.Empty
connectionstext box.Text = String.Empty
premiumquantity textbox.Text = String.Empty
channelpricetex tbox.Text = String.Empty
channeltextbox. Text = String.Empty
amountduetextbo x.Text = String.Empty
TextBox4.Text = String.Empty
End Sub
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
End Sub
End Class[/code]
'Project Name: Tammy Seilheimer
'Project Purpose: This project calculates a customer's bill for cable services
'Created By: Tammy Seilheimer
[code=vbnet]
Option Explicit On
Public Class Form1
Private Sub residentialButt on_CheckedChang ed(ByVal sender As Object, ByVal e As System.EventArg s) Handles residentialbutt on.CheckedChang ed
connectionstext box.Visible = False
connectionsquan titytextbox.Vis ible = False
TextBox4.Visibl e = False
Label7.Visible = False
Label8.Visible = False
End Sub
Private Sub businessbutton_ checkedchanged( ByVal sender As Object, ByVal e As System.EventArg s) Handles businessbutton. CheckedChanged
connectionstext box.Visible = True
connectionsquan titytextbox.Vis ible = True
TextBox4.Visibl e = True
Label7.Visible = True
Label8.Visible = True
End Sub
Private Sub calculatebutton _Click(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles calculatebutton .Click
If residentialbutt on.Checked Then
Dim channelprice As Decimal
Dim residentialnumb erofchannels As Integer
Dim residentialchan neltotalprice As Decimal
Dim residentialamou ntdue As Decimal
Dim processingfee As Decimal
Dim basicfee As Decimal
Dim isconverted As Boolean
Dim isconverted2 As Boolean
Dim isconverted3 As Boolean
Dim isconverted4 As Boolean
isconverted = Integer.TryPars e(channelpricet extbox.Text, channelprice)
isconverted2 = Integer.TryPars e(processingtex tbox.Text, processingfee)
isconverted3 = Integer.TryPars e(basicfeetextb ox.Text, basicfee)
isconverted4 = Integer.TryPars e(premiumquanti tytextbox.Text, residentialnumb erofchannels)
'connectionstex tbox.Visible = False
'connectionsqua ntitytextbox.Vi sible = False
' TextBox4.Visibl e = False
'Label7.Visible = False
'Label8.Visible = False
If isconverted4 = True Then
processingfee = 4.5
basicfee = 30
channelprice = 5
premiumquantity textbox.Text = residentialnumb erofchannels
channelpricetex tbox.Text = channelprice.To String("C2")
residentialchan neltotalprice = (residentialnum berofchannels * channelprice)
channeltextbox. Text = residentialchan neltotalprice.T oString("C2")
processingtextb ox.Text = processingfee.T oString("C2")
basicfeetextbox .Text = basicfee.ToStri ng("C2")
residentialamou ntdue = (processingfee + basicfee + residentialchan neltotalprice)
amountduetextbo x.Text = residentialamou ntdue.ToString( "C2")
End If
End If
If businessbutton. Checked Then
Dim businessnumbero fchannels As Integer
Dim businessnumbero fconnections As Integer
Dim businesschannel totalprice As Decimal
Dim businessconnect ionstotalprice As Decimal
Dim businessamountd ue As Decimal
Dim channelprice As Decimal
Dim isconverted5 As Boolean
Dim isconverted6 As Boolean
Dim processingfee As Decimal
Dim basicfee As Decimal
Dim connectionprice As Decimal
isconverted5 = Integer.TryPars e(connectionsqu antitytextbox.T ext, businessnumbero fconnections)
isconverted6 = Integer.TryPars e(premiumquanti tytextbox.Text, businessnumbero fchannels)
If isconverted5 = True Then
processingfee = 16.5
basicfee = 80
channelprice = 50
connectionprice = 4
businessconnect ionstotalprice = businessnumbero fconnections * 4
businessnumbero fconnections = connectionsquan titytextbox.Tex t
channelpricetex tbox.Text = channelprice.To String("C2")
connectionstext box.Text = businessconnect ionstotalprice. ToString("C2")
TextBox4.Text = connectionprice .ToString("C2")
processingtextb ox.Text = processingfee.T oString("C2")
basicfeetextbox .Text = basicfee.ToStri ng("C2")
businesschannel totalprice = businessnumbero fchannels * 50
channeltextbox. Text = businesschannel totalprice.ToSt ring("C2")
businessnumbero fchannels = premiumquantity textbox.Text
businessamountd ue = (businesschanne ltotalprice + processingfee + basicfee + businessconnect ionstotalprice)
amountduetextbo x.Text = businessamountd ue.ToString("C2 ")
End If
End If
End Sub
Private Sub exitbutton_Clic k(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles Exitbutton.Clic k
Me.Close()
End Sub
Private Sub clearbutton_Cli ck(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles clearbutton.Cli ck
processingtextb ox.Text = String.Empty
basicfeetextbox .Text = String.Empty
connectionsquan titytextbox.Tex t = String.Empty
connectionstext box.Text = String.Empty
premiumquantity textbox.Text = String.Empty
channelpricetex tbox.Text = String.Empty
channeltextbox. Text = String.Empty
amountduetextbo x.Text = String.Empty
TextBox4.Text = String.Empty
End Sub
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
End Sub
End Class[/code]
Comment