Friday 15 March 2013

vb.net - Visual Basic Hospital Stay Calculator -



vb.net - Visual Basic Hospital Stay Calculator -

so writing programme should homecoming total cost of hospital stay. appears working fine, except of import part...the total cost of hospital stay. have looked everywhere possible solution, no avail. programme continues homecoming $0.00 no matter do. no error messages, $0.00 every single time. realize have not included exception handling of yet, 1 time kinks worked out. thought issue here? in advance!

const decrateperday decimal = 350.0 private sub btncalculate_click(sender object, e eventargs) handles btncalculate.click dim numofdays integer dim medcharges decimal dim surgicalcharges decimal dim labfees decimal dim rehabcharges decimal dim totalcharges decimal numofdays = cdec(txtnumofdays.text) medcharges = cdec(txtmedcharges.text) surgicalcharges = cdec(txtsurgicalcharges.text) labfees = cdec(txtlabfees.text) rehabcharges = cdec(txtlabfees.text) lblcaltotalcost.text = totalcharges.tostring("c") end sub function calcstaycharges(numofdays integer) decimal dim deccostofstay decimal numofdays = cdec(txtnumofdays.tostring) deccostofstay = numofdays * decrateperday homecoming deccostofstay end function function calcmisccharges(medcharges decimal, surgicalcharges decimal, labfees decimal, rehabcharges decimal) decimal dim totalmisc decimal medcharges = cdec(txtmedcharges.tostring) surgicalcharges = cdec(txtsurgicalcharges.tostring) labfees = cdec(txtlabfees.tostring) rehabcharges = cdec(txtlabfees.tostring) totalmisc = medcharges + surgicalcharges + labfees + rehabcharges homecoming totalmisc end function function calctotalcharges(costofstay decimal, totalmisc decimal) decimal dim totalcharges decimal totalcharges = costofstay + totalmisc lblcaltotalcost.text = totalcharges.tostring("c") homecoming totalcharges end function

you never set value of totalcharges , never phone call functions calculate total charges.

change

lblcaltotalcost.text = totalcharges.tostring("c")

to

lblcaltotalcost.text = calctotalcharges(calcstaycharges(numofdays), _ calcmisccharges(medcharges, surgicalcharges, labfees, rehabcharges)) _ .tostring("c")

vb.net visual-studio-2010

No comments:

Post a Comment