vb.net - Creating a checkbook application -


i trying create checkbook application class transaction type such as, deposit, check, or service charges. decide transaction clicked , amount , display balance. determine if there insufficient funds. if there insufficient funds not process check , charge $10 dollar fee. keep track of number of deposits, checks, , service charges keep total amount of money deposits, checks, , service charges. having trouble last part. here explanation of needs done: transactions being entered user need add logic keep track of count , amount each transaction type (deposit, check, , service charge).

for summary information should display:

total number of deposits
total dollar amount of deposits
total number of checks
total dollar amount of checks
total number of service charges
total dollar amount of service charges
add summary button form. when user clicks summary button use single messagebox display summary information user. need build string contain count , amount each transaction type shown above.

right number of deposits, checks, , service charges won't print out right , can't figure out how keep track of total amount of money placed in deposits, checks, , service charges. insufficient fund logic not working either. instructor says problem within calculatebutton_click. in advance.

here code:

option strict on public class form1     dim balance double     dim numdeposits long = 0     dim numchecks long = 0     dim numcharges long = 0     dim amountdeposits, amountchecks, amountcharges double     dim transamount double     private property program string        private sub calculatebtn_click(byval sender system.object, byval e system.eventargs) handles calculatebtn.click           'get transaction amount textbox         transamount = cdbl(amountbox.text)          'when check button clicked check see if transaction amount larger         'than balance if display message box , apply service charge of $10         if checkbtn.checked , transamount > balance             balance = balance - 10             msgbox("insufficient funds")          end if          'if user inputs transaction amount negative number         'display message box         if transamount < 0             msgbox("enter valid number")         end if          'check see if transaction amount numeric         if isnumeric(transamount)             calculatebtn.enabled = true         end if          'decide operation use depending on radio button clicked         if depositbtn.checked             balance = balance + transamount         elseif checkbtn.checked             balance = balance - transamount         elseif servicebtn.checked             balance = balance - transamount         end if          'print balance         balancelbl.text = balance.tostring("c2")     end sub      private sub exitbtn_click(byval sender system.object, byval e system.eventargs) handles exitbtn.click         'when exit button clicked close program         me.close()     end sub      private sub aboutbtn_click(byval sender system.object, byval e system.eventargs) handles aboutbtn.click         'display 'about' information         messagebox.show("program name: checkbook" & environment.newline & environment.newline &                         "programmer: stephanie correa" & environment.newline & environment.newline &                         "description: checkbook application track transactions" & environment.newline &                         environment.newline & "version 2.30")     end sub     private sub amountbox_textchanged(byval sender system.object, byval e system.eventargs) handles amountbox.textchanged         'if transaction amount valid numeric value enable calculate button         if isnumeric(amountbox.text)             calculatebtn.enabled = true         else             calculatebtn.enabled = false         end if     end sub      private sub summarybtn_click(byval sender system.object, byval e system.eventargs) handles summarybtn.click          'print summary of transactions         messagebox.show("number of deposits: " & numdeposits & environment.newline & "number of checks: " &                numchecks & environment.newline & "number of service charges: " & numcharges & environment.newline &                "amount deposits: " & amountdeposits)      end sub      private sub depositbtn_checkedchanged(byval sender system.object, byval e system.eventargs) handles depositbtn.checkedchanged         'keep track of amount of deposits , total amount of money deposited         dim sum long = 0          sum = sum + 1         numdeposits = sum          amountdeposits += transamount     end sub      private sub checkbtn_checkedchanged(byval sender system.object, byval e system.eventargs) handles checkbtn.checkedchanged         'keep track of amount of checks , total amount of money checks          dim checksum long = 0          checksum = checksum + 1         numchecks = checksum          amountchecks += transamount     end sub      private sub servicebtn_checkedchanged(byval sender system.object, byval e system.eventargs) handles servicebtn.checkedchanged         'keep track of amount of service charges , amount of money charges         dim chargessum long = 0         chargessum = chargessum + 1         numcharges = chargessum          amountcharges = 0         amountcharges += transamount     end sub end class 

it looks performing counts in wrong place.

option strict on public class form2 ' dim balance double dim numdeposits, numchecks, numcharges long dim amountdeposits, amountchecks, amountcharges double dim transamount double ' private property program string ' private sub calculatebtn_click(byval sender system.object, byval e system.eventargs) handles calculatebtn.click       'get transaction amount textbox     transamount = cdbl(amountbox.text)      'if user inputs transaction amount negative number display message box     if transamount < 0         msgbox("enter valid number")     else         'decide operation use depending on radio button clicked         if depositbtn.checked             numdeposits = numdeposits + 1             amountdeposits = amountdeposits + transamount             balance = balance + transamount             msgbox(transamount & " deposited")             amountbox.text = ""         elseif checkbtn.checked             'when check button clicked check see if transaction amount larger             'than balance if display message box , apply service charge of $10             if transamount > balance                 numcharges = numcharges + 1                 amountcharges = amountcharges + 10                 balance = balance - 10                 msgbox("insufficient funds, $10 service charge incurred!")             else                 numchecks = numchecks + 1                 amountchecks = amountchecks + transamount                 balance = balance - transamount                 msgbox(transamount & " check accepted")                 amountbox.text = ""             end if         elseif servicebtn.checked             balance = balance - transamount             msgbox(transamount & " service charges applied")             amountbox.text = ""         end if         'print balance         balancelbl.text = balance.tostring("c2")         'print checks         lblchecks.text = amountchecks.tostring("c2") & "[" & numchecks & "]"         'print charges         lblcharges.text = amountcharges.tostring("c2") & "[" & numcharges & "]"         'print deposits         lbldeposits.text = amountdeposits.tostring("c2") & "[" & numdeposits & "]"     end if  end sub  private sub exitbtn_click(byval sender system.object, byval e system.eventargs)     'when exit button clicked close program     me.close() end sub  private sub aboutbtn_click(byval sender system.object, byval e system.eventargs) handles aboutbtn.click     'display 'about' information     messagebox.show("program name: checkbook" & environment.newline & environment.newline &                     "programmer: stephanie correa" & environment.newline & environment.newline &                     "description: checkbook application track transactions" & environment.newline &                     environment.newline & "version 2.30") end sub  private sub amountbox_textchanged(byval sender system.object, byval e system.eventargs) handles amountbox.textchanged     'if transaction amount valid numeric value enable calculate button     if isnumeric(amountbox.text)         calculatebtn.enabled = true     else         calculatebtn.enabled = false     end if end sub  private sub summarybtn_click(byval sender system.object, byval e system.eventargs) handles summarybtn.click      'print summary of transactions     messagebox.show("number of deposits: " & numdeposits & environment.newline & "number of checks: " &            numchecks & environment.newline & "number of service charges: " & numcharges & environment.newline &            "amount deposits: " & amountdeposits)  end sub  end class 

enter image description here


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -