newbie calculator problem

mindflayerz

Member
Joined
May 14, 2005
Messages
5
Programming Experience
Beginner
hi everyone im new here been doing vb .net for about 15 weeks, can anyone tell me whats wrong with my code when i click my cancel button?
 

Attachments

  • VB.txt
    2.5 KB · Views: 40
ah yeah mdectotal is
private mdectotal as decimal

its the module level variable thingy to keep adding the sales to calculate the average.
 
Since I don't have any experiance with the InputBox, I found the solution by adding a breakpoint to the code and stepping through the code.
The problem is that you're checking for a value of -1. When you click cancel, strInputNum equals an empty string (String.Empty). Change 'Do Until strInputNum = "-1"' to 'Do Until strInputNum = String.Empty'.
I would also suggest resetting the value of mdectotal at the beginning of the procedure; if the user doesn't click BtnClear after running the calculations previously you will get incorrect results.
Also, add a message in the InputBox to let the user know that clicking Cancel will end the input stage and allow the numbers to be calculated.
 
Back
Top