[RESOLVED] Pressing Calculate button a 2nd time zeros 2 variables
Gentlemen:
A form with 6 variables now behaves properly in the first run of entering the 6 variables, and pressing the calculate command button.
But if the same calculate button is again pressed two of the variables namely the first and the last which call for Currency values are zeroed out.
I also get an error in the value of the final calculation if I change any of the variable values on the form. The process again zeros out the first and last fields.
Attached is a zipped of the form, and code.
Any suggestions????
Last edited by ortizsr; Jun 29th, 2005 at 07:49 PM.
Reason: Resolved
Re: Pressing Calculate button a 2nd time zeros 2 variables
when you first run the command the textbox is holding a numeric value so if the textbox held say 23
TmpPrice = Val(TxtPrice.Text), TmpPrice becomes 23 but then you format the textbox to show a currency format, $23.00. Now, if you run the command again, the Val() function wont recognise it because of the currency symbol and it will return zero. try this instead
Re: Pressing Calculate button a 2nd time zeros 2 variables
I ran your program and it had several errors.
First of all the Down payment is specified in % not dollars so let the user know this.
The problem is that you are reformatting the text the user enters, so the next time you press the button it assumes it has user entered data rather than the new formatted data
You can expect Val(100000) to give the same results as Val($100,000)
Edit: VBA SIC GIRL has beat me to it
One more suggestion
most Users hate it when a program asks if they really want to exit.
Re: Pressing Calculate button a 2nd time zeros 2 variables
Dear Moeur:
Thank you for your observations. I followed through on Vbasicgirl's tips and all is well now.
Please you mention that Users do not like to prompted for an Exit option..
What do you suggest instead - The X on the form or something other that that.
I have not finished writing up the Help section for this application, and so I apologize for not indicating that the Dwn Pmt calls for a number between 0 and 99.
Thanks again.
I copied your 3 code submissions, and will study them later. I am but a beginner in VB6, and the questions raised pertain to my first application in VB6. Thanks for the links.
Last edited by ortizsr; Jun 29th, 2005 at 05:32 PM.
Re: Pressing Calculate button a 2nd time zeros 2 variables
The problem you face when trying to calculate something automatically is knowing when the user as actually finished typing everything in the fields. I would keep things user friendly and just make sure the tab index's are in order and maybe put the Default property of the calculation command button to true (pressing enter activates it). Following moeur's point of the exit, is there anything major that could be lost by accidently closing the program ?, if not then theres no real need for it.