- The number of days spent in the hospital
- The amount of medication charges
- The amount of surgical charges
- The amount of lab fees
- The amount of physical rehabilitation charges
The hospital charges $350 per day.
Create the following functions:
CalcStayCharges Calculates and returns the base charges for the hospital stay. The is compound as $350 times the number of days in the hospital.
CalcMiscCharges Calculates and returns the total of the medication, surgical, lab, and physical rehabilitation charges.
CalcTotalCharges Calculates and returns the total charges.
Input Validation: Do not accept a negative value for length of stay, medication charges, surgical charges, lab fees, or physical rehabilitation charges.
There will be 5 text boxes: Length of Stay (Days), Medication, Surgical Charges, Lab Fees and Physical. A label should contain the Total Cost. There will be three buttons: Calculate Charges, Clear Form and Close
**I need help writing the correct code so this problem executes properly. Thanks!**
This is what I have so far. I am lost. Please help
Private Sub btnCalculate_Click(sender As System.Object, e As System.EventArgs) Handles btnCalculate.Click
'This procedure calculates the total amount of a hospital stay
Dim SurgicalCharges As Decimal
Dim LabFees As Decimal
Dim MedicationCharge As Decimal
Dim PhysicalCharge As Decimal
Dim LengthOfStay As Integer
'This procedure calculates the total misc expenses of a hospital stay
If Not Decimal.TryParse(txtCharges.Text, SurgicalCharges) Then
MessageBox.Show("Please enter numeric value for surgical charges")
ElseIf Not Decimal.TryParse(txtFees.Text, LabFees) Then
MessageBox.Show("Please enter numeric value for Lab Fees")
ElseIf Not Decimal.TryParse(txtMedication.Text, MedicationCharge) Then
MessageBox.Show("Please enter numeric value for Medication Charge")
ElseIf Not Decimal.TryParse(txtPhysical.Text, PhysicalCharge) Then
MessageBox.Show("Please enter numeric value for Physical Charge")
ElseIf Not Integer.TryParse(txtStay.Text, LengthOfStay) Then
MessageBox.Show("Please enter numeric value for Lenth of stay")
Else
'Calculate total charges
lblTotalCost.Text =
End If
End Sub
Function CalcStayCharges(ByVal Days As Double) As Double
Dim StayCharges As Double
'Calculate Stay Charges
Days = CInt(txtStay.Text)
StayCharges = Days * 350
CalcStayCharges = CDbl(StayCharges.ToString)
'Testing results
MessageBox.Show(CalcStayCharges.ToString("c"))
lblTotalCost.Text = CStr(CalcStayCharges.ToString)
Return CalcStayCharges
End Function
Function CalcMiscCharges(ByVal Medication As Decimal, ByVal Charges As Decimal,
ByVal Fees As Decimal, ByVal Physical As Decimal) As Decimal
Dim MiscCharges As Decimal
Medication = CDec(txtMedication.Text)
Charges = CDec(txtCharges.Text)
Fees = CDec(txtFees.Text)
Physical = CDec(txtPhysical.Text)
'Calculate misc charges
MiscCharges = Medication + Charges + Fees + Physical
CalcMiscCharges = CDec(MiscCharges.ToString)
MessageBox.Show(CalcMiscCharges.ToString)
Return CalcMiscCharges
End Function
Function CalcTotalCharges(ByVal TotalCost As Decimal) As Decimal
Dim StayCharges As Decimal
Dim MiscCharges As Decimal
TotalCost = StayCharges + MiscCharges
CalcTotalCharges = CDec(TotalCost.ToString)
Return CalcTotalCharges + MiscCharges
End Function
Private Sub btnClear_Click() Handles btnClear.Click
'Clears all text boxes
txtStay.Clear()
txtMedication.Clear()
txtCharges.Clear()
txtFees.Clear()
txtPhysical.Clear()
'Clear label boxes
lblTotalCost.Text = String.Empty
End Sub
Private Sub btnExit_Click() Handles btnExit.Click
'Ends the application
Me.Close()
End Sub
End Class

New Topic/Question
Reply



MultiQuote








|