vb.net - Visual Basic - Simple Bank Transaction -
i believe working correctly cannot labels display calculated data, don't know messed here. appreciated.
imports system.io public class form1 dim decmakewithdrawal decimal dim decbalace decimal private sub btnexit_click(sender object, e eventargs) handles btnexit.click 'close form me.close() end sub private sub btndeposit_click(sender object, e eventargs) handles btndeposit.click dim decmakedeposit decimal 'add deposit decmakedeposit = cdec(inputbox("please enter deposit if have any")) end sub public sub btnwithdraw_click(sender object, e eventargs) handles btnwithdraw.click dim decbalance decimal decmakewithdrawal = cdec(inputbox("please enter amount withdraw")) if decbalance <= 0 messagebox.show("insufficient funds") end if end sub private sub mainform_load(sender object, e eventargs) handles mybase.load dim decintrate decimal decintrate = cdec(inputbox("please enter interest rate:")) end sub private function decinttrans() object throw new notimplementedexception end function private sub btncalculate_click(sender object, e eventargs) handles btncalculate.click dim decintertrans decimal dim decinterest decimal decinterest = cdec(decinttrans()) decintertrans += 1d end sub end class public class transaction 'create member variables properties public decbalance decimal private decintrate decimal private decinterest decimal private inttrans integer private decmakewithdrawal decimal private decmakedeposit decimal private decinterestearned decimal 'create property procedures public property balance decimal return decbalance end set(value decimal) decbalance = value end set end property public property intrate double return decintrate end set(value double) decintrate = cdec(value) end set end property public property interesttotal double return decinterest end set(value double) decinterest = cdec(value) end set end property 'calculate amount of interest current period 'stores value in interest property, , adds balance property public sub addinterest(byval addinterest integer) decinterestearned = decbalance * (decintrate / 12) end sub 'add deposit public sub adddeposit(byval adddeposit decimal) decmakedeposit += adddeposit end sub 'withdraw public sub subtractwithdrawl(byval subtractwithdrawal double) if decmakewithdrawal >= subtractwith() decmakewithdrawal = cdec(decmakewithdrawal - subtractwith()) else messagebox.show("no sufficient balance") end if end sub private function subtractwith() double throw new notimplementedexception end function end class
i feel code being complicated stuff have added not using @ present.
so things, i've cut stuff out , corrected errors see. lot of tweaking still needed , member blackwood states should validate values input user before processing data.
yet still, start off , set on right path, try code below , don't forget compare original can see going wrong.
good luck
option explicit imports system.io public class form1 dim mytransactor transaction private sub mainform_load(sender object, e eventargs) handles mybase.load dim decintrate decimal mytransactor = new transaction() decintrate = cdec(inputbox("please enter interest rate:")) mytransactor.intrate = decintrate end sub private sub btnexit_click(sender object, e eventargs) handles btnexit.click 'close form me.close() end sub private sub btndeposit_click(sender object, e eventargs) handles btndeposit.click dim decmakedeposit decimal decmakedeposit = cdec(inputbox("please enter deposit if have any")) mytransactor.adddeposit = decmakedeposit end sub public sub btnwithdraw_click(sender object, e eventargs) handles btnwithdraw.click decmakewithdrawal = cdec(inputbox("please enter amount withdraw")) mytransactor.subtractwithdrawl = decmakewithdrawal end sub private sub btncalculate_click(sender object, e eventargs) handles btncalculate.click mytransactoraddinterest messagebox.show(mytransactor.interestearned & "interest add balance. total balance " & mytranasactor.balance) end sub end class public class transaction 'create member variables properties public decbalance decimal private decintrate decimal private decinterestearned decimal 'create property procedures public property balance decimal return decbalance end set(value decimal) decbalance = value end set end property public property intrate double return decintrate end set(value double) decintrate = cdec(value) end set end property public property interestearned double return decinterestearned end set(value double) decinterestearned = cdec(value) end set end property 'calculate amount of interest current period 'stores value in interest property, , adds balance property public sub addinterest() decinterestearned = decbalance * (decintrate / 12) decbalance =+ decinterestearned end sub 'add deposit public sub adddeposit(byval depositvalue decimal) decbalance=+ depositvalue end sub 'withdraw public sub subtractwithdrawl(byval withdrawalvalue double) if decbalance >= withdrawalvalue decbalance =- withdrawalvalue else messagebox.show("no sufficient balance") end if end sub end class
Comments
Post a Comment