Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 7 of 7

Thread: Simple math

  1. #1
    Join Date
    Mar 2004
    Location
    Alabama
    Posts
    109

    Grin Simple math

    Can someoone plese post the code to take 2 or 3 text boxes. enter numbers into each then add, subtract, multiply, etc and output the results into another text box or paragraph.



    Thanks.

  2. #2
    Join Date
    Jul 2003
    Posts
    712
    Hello,

    Here's the simplest way i could think of to do this. obviously you'll want to add checks (in case, for example, one input is left blank . . . )

    But this example covers the math of what you are trying to do (or at least, what I think you're trying to do!! )

    Enjoy,
    Desmond.
    Attached Files

  3. #3
    Join Date
    Mar 2004
    Location
    Alabama
    Posts
    109

    Round up or down?

    That was what I needed. Thanks.

    Now if I want to round up everything that is a fraction how would I use that just for the total box?

    I looked at the math.ceil function but I was not sure how to implement it using a textbox for result.

    your_number = 3.1415;
    your_rounded_number = Math.Ceil(your_number);

    Say my number is 46.1 and I am going to call it value 6 and display it into Input4

    Input.SetText("Input4", value6)

  4. #4
    Join Date
    Apr 2001
    Posts
    92
    I am not sure if I understood your question correctly. If you have 46.1 and want to end up with 47, then the following code should do it:

    value5 = 46.1
    value6 = Math.Ceil(value5);
    Input.SetText("Input4", value6);

  5. #5
    Corey is offline Indigo Rose Staff Alumni
    Join Date
    Aug 2002
    Posts
    9,746
    cchian just FYI, you should be able to use:

    value5 = Math.Ceil(value5);

    Or for that matter:

    Input.SetText("Input4", Math.Ceil(value5));

    Corey Milner
    Creative Director, Indigo Rose Software

  6. #6
    Join Date
    Mar 2004
    Location
    Alabama
    Posts
    109

    One more related question

    That took care of it.

    One last (I hope) problem on this.
    If I put a letter instead of a number into the texboxes it gives me an error.
    How do I make sure someone only enters numbers instead of letter, etc.?

    Patrick

  7. #7
    Join Date
    Apr 2001
    Posts
    92
    Do a search for "Masked Input" and you will be able to do exactly what you are asking

Posting Permissions

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