# Help With Hospital Charges Form

Page 1 of 1

## 11 Replies - 10320 Views - Last Post: 06 December 2012 - 04:57 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=303022&amp;s=d15d581eec835e9332d15321daa8eac6&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 mjmrcng

• New D.I.C Head

Reputation: 0
• Posts: 16
• Joined: 10-November 12

# Help With Hospital Charges Form

Posted 06 December 2012 - 01:44 PM

Create an application that calculates the total cost of a hospital stay. The application should accept the following input:

- 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

```

Is This A Good Question/Topic? 0

## Replies To: Help With Hospital Charges Form

### #2 modi123_1

• Suitor #2

Reputation: 11614
• Posts: 45,778
• Joined: 12-June 08

## Re: Help With Hospital Charges Form

Posted 06 December 2012 - 01:46 PM

Quote

**I need help writing the correct code so this problem executes properly. Thanks!**

What do you mean?

Quote

This is what I have so far. I am lost.

Lost how?
Was This Post Helpful? 0

### #3 mjmrcng

• New D.I.C Head

Reputation: 0
• Posts: 16
• Joined: 10-November 12

## Re: Help With Hospital Charges Form

Posted 06 December 2012 - 01:53 PM

modi123_1, on 06 December 2012 - 01:46 PM, said:

Quote

**I need help writing the correct code so this problem executes properly. Thanks!**

What do you mean?

Quote

This is what I have so far. I am lost.

Lost how?

I can't figure out what I am doing wrong. I was wondering if anyone could help me solve this problem.
Was This Post Helpful? 0

### #4 modi123_1

• Suitor #2

Reputation: 11614
• Posts: 45,778
• Joined: 12-June 08

## Re: Help With Hospital Charges Form

Posted 06 December 2012 - 01:59 PM

You need to explain to us what is going wrong. We are not there with you, right? You need to be clear about any error messages you are getting: what are they and what line are they one? Is the program not working as expected? If so what is it doing and what *should* it be doing?
Was This Post Helpful? 0

### #5 mjmrcng

• New D.I.C Head

Reputation: 0
• Posts: 16
• Joined: 10-November 12

## Re: Help With Hospital Charges Form

Posted 06 December 2012 - 02:31 PM

modi123_1, on 06 December 2012 - 01:59 PM, said:

You need to explain to us what is going wrong. We are not there with you, right? You need to be clear about any error messages you are getting: what are they and what line are they one? Is the program not working as expected? If so what is it doing and what *should* it be doing?

I am not getting any error messages.. It just won't calculate the total hospital cost. All the info is in the question above the code.
Was This Post Helpful? 0

### #6 modi123_1

• Suitor #2

Reputation: 11614
• Posts: 45,778
• Joined: 12-June 08

## Re: Help With Hospital Charges Form

Posted 06 December 2012 - 02:41 PM

Quote

I am not getting any error messages.. It just won't calculate the total hospital cost. All the info is in the question above the code.

To be clear - no, the explanation of what is happening is not found in your write up of your homework.
Was This Post Helpful? 0

### #7 mjmrcng

• New D.I.C Head

Reputation: 0
• Posts: 16
• Joined: 10-November 12

## Re: Help With Hospital Charges Form

Posted 06 December 2012 - 03:03 PM

modi123_1, on 06 December 2012 - 02:41 PM, said:

Quote

I am not getting any error messages.. It just won't calculate the total hospital cost. All the info is in the question above the code.

To be clear - no, the explanation of what is happening is not found in your write up of your homework.

Do you know how to solve this problem?
Was This Post Helpful? 0

### #8 modi123_1

• Suitor #2

Reputation: 11614
• Posts: 45,778
• Joined: 12-June 08

## Re: Help With Hospital Charges Form

Posted 06 December 2012 - 03:14 PM

Do I know how to write the code for the assignment? Yes.
Was This Post Helpful? 0

### #9 mjmrcng

• New D.I.C Head

Reputation: 0
• Posts: 16
• Joined: 10-November 12

## Re: Help With Hospital Charges Form

Posted 06 December 2012 - 03:38 PM

mjmrcng, on 06 December 2012 - 03:03 PM, said:

modi123_1, on 06 December 2012 - 02:41 PM, said:

Quote

I am not getting any error messages.. It just won't calculate the total hospital cost. All the info is in the question above the code.

To be clear - no, the explanation of what is happening is not found in your write up of your homework.

Do you know how to solve this problem?

You see the code I have.. That's why I posted it on here. Can you help or not?
Was This Post Helpful? 0

### #10 modi123_1

• Suitor #2

Reputation: 11614
• Posts: 45,778
• Joined: 12-June 08

## Re: Help With Hospital Charges Form

Posted 06 December 2012 - 03:48 PM

*sigh* I am still not understanding what is wrong. Sure.. you have some code there.. and in some nebulous way it isn't matching your multi part homework...but you are not explaining which parts or what lines, or any of the typical jazz.

If you want me to meticulously go through each line to compare it to the homework's multipoint goal and turn back a completed chunk of code that matches the homework goals then you need to pony up cash for that sort of free lance work.
Was This Post Helpful? 0

### #11 mjmrcng

• New D.I.C Head

Reputation: 0
• Posts: 16
• Joined: 10-November 12

## Re: Help With Hospital Charges Form

Posted 06 December 2012 - 04:14 PM

modi123_1, on 06 December 2012 - 03:48 PM, said:

*sigh* I am still not understanding what is wrong. Sure.. you have some code there.. and in some nebulous way it isn't matching your multi part homework...but you are not explaining which parts or what lines, or any of the typical jazz.

If you want me to meticulously go through each line to compare it to the homework's multipoint goal and turn back a completed chunk of code that matches the homework goals then you need to pony up cash for that sort of free lance work.

I can't do that lol.. I will just ask my college professor. Thanks for your help!
Was This Post Helpful? 0

### #12 mjmrcng

• New D.I.C Head

Reputation: 0
• Posts: 16
• Joined: 10-November 12

## Re: Help With Hospital Charges Form

Posted 06 December 2012 - 04:57 PM

modi123_1, on 06 December 2012 - 01:59 PM, said:

You need to explain to us what is going wrong. We are not there with you, right? You need to be clear about any error messages you are getting: what are they and what line are they one? Is the program not working as expected? If so what is it doing and what *should* it be doing?

I am getting this error message when I try to add calcMiscCharges + CalcStayCharges

Argument not specified for parameter 'Physical' of 'Public Function CalcMiscCharges(Medication As Decimal, Charges As Decimal, Fees As Decimal, Physical As Decimal) As Decimal'

```      'Calculate total charges
lblTotalCost.Text = CalcStayCharges + CalcMiscCharges

```

Was This Post Helpful? 0

Page 1 of 1

 .related ul{list-style-type:circle;font-size:12px;font-weight:bold;}.related li{margin-bottom:5px;background-position:left 7px!important;margin-left:-35px;}.related h2{font-size:18px;font-weight:bold;}.related a{color:blue;}