Results 1 to 8 of 8

Thread: [RESOLVED] Pressing Calculate button a 2nd time zeros 2 variables

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2005
    Location
    Boca Raton, FLorida, USA
    Posts
    33

    Resolved [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????
    Attached Files Attached Files
    Last edited by ortizsr; Jun 29th, 2005 at 07:49 PM. Reason: Resolved
    Respectfully,
    Herman Ortiz

  2. #2
    Fanatic Member vbasicgirl's Avatar
    Join Date
    Jan 2004
    Location
    Manchester, UK
    Posts
    1,016

    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

    TmpPrice = CCur(TxtPrice.Text)

    casey.

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2005
    Location
    Boca Raton, FLorida, USA
    Posts
    33

    Re: Pressing Calculate button a 2nd time zeros 2 variables

    Dear Miss VBasicgirl:

    Thank you for the tip. I shall try it, and report any success.

    Thanks again.




    Back again:

    It worked very well by changing all Currency values to use the CCur for the Textboxes.

    Now I can change any variable on the form and the recalculation works.


    May I present another question on this same topic:

    How do I code for the calculations to be made and displayed automatically without resorting to the use of the Calculate Button???


    Last edited by ortizsr; Jun 29th, 2005 at 05:16 PM.
    Respectfully,
    Herman Ortiz

  4. #4
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    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.

  5. #5

    Thread Starter
    Member
    Join Date
    Jun 2005
    Location
    Boca Raton, FLorida, USA
    Posts
    33

    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.
    Respectfully,
    Herman Ortiz

  6. #6
    Fanatic Member vbasicgirl's Avatar
    Join Date
    Jan 2004
    Location
    Manchester, UK
    Posts
    1,016

    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.

    casey.

  7. #7
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Pressing Calculate button a 2nd time zeros 2 variables

    The Exit button is OK, but why then does the user have to press a second button confirming his intentions?

  8. #8

    Thread Starter
    Member
    Join Date
    Jun 2005
    Location
    Boca Raton, FLorida, USA
    Posts
    33

    Re: Pressing Calculate button a 2nd time zeros 2 variables

    Dear Vbasicgirl and Moeur:

    Thank you very much for your help.

    Now I understand your point on the merits of the confimation of exiting. -I agree it is unnecessary.

    As to the automation of the calculate I changed the default property to true, and will retest.

    Thanks again. your help was quick and very efficient.
    Respectfully,
    Herman Ortiz

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width