Hospital Charges (VB)

Hospital Charges (VB)

Public Class Form1
'Variable declartion
Dim intDays As Integer = 0
Dim decMedication As Decimal = 0
Dim decSurgical As Decimal = 0
Dim decLab As Decimal = 0
Dim decPhysical As Decimal = 0



Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
Dim decTotal As Decimal 'Holds subtotal
If ValidateInputFields() = True Then 'Data validation
decTotal = CalcTotalCharges() 'Calculate the total based on functions.
lblTotal.Text = decTotal.ToString("c")
End If
End Sub

Function CalcStayCharges() As Decimal 'Calc stay charges.
Dim decTotal As Decimal = 0 'Variables to hold total
decTotal = intDays * 350 'Calculate
Return decTotal 'Return value
End Function

Function CalcMiscCharges() As Decimal 'Calc misc charges.
Dim decTotal As Decimal = 0 'Variable to hold total
decTotal = decMedication + decSurgical + decLab + decPhysical 'Calculate
Return decTotal 'Return value
End Function

Function CalcTotalCharges() As Decimal 'Calc total charges.
Dim decTotal As Decimal = 0 'Variable to hold total
decTotal = CalcStayCharges() + CalcMiscCharges() 'Calculate
Return decTotal 'Return value
End Function

Function ValidateInputFields() As Boolean
Dim boolFlag As Boolean = True 'Flag variable
'Test data and store it, see if it is positive, if it does not
'successfully store or it is less than 0 set flag to false and
'an appropriate label status.
Try
intDays = CInt(txtDays.Text)
Catch
lblStatus.Text =...

Similar Essays