Results 1 to 6 of 6

Thread: Math Help Needed [Resolved]

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2003
    Posts
    127

    Math Help Needed [Resolved]

    If this is an easy question please excuse me. I am new to VB.NET and have made a few small programs that randomize numbers but I want to learn some math now and need a working code example.

    I want to have a series of text boxes 1 thru 10. The math formula I need help with is below. If it's easy enough I would like the calculations to occur when the numbers are typed in the text boxes by the user like an on change event. If it's easier to use a button to do all the caluclations after the numbers have been entered in the text boxes that would be ok too.

    textbox1 minus textbox2 plus textbox3 = textbox4
    textbox4 minus textbox5 plus textbox6 = textbox7
    textbox7 minus textbox8 plus textbox9 = textbox10


    Thanks for help with this.
    Last edited by teamdad; Jun 13th, 2004 at 08:19 PM.

  2. #2
    New Member
    Join Date
    Apr 2004
    Posts
    1
    Well i personally would create variables for user input.
    But my code would look like this:

    dim sngInput1 as single
    dim sngInput2 as single
    dim sngInput3 as single
    dim sngInput5 as single
    dim sngInput6 as single
    dim sngInput8 as single
    dim sngInput9 as single
    dim sngoutput1 as single
    dim sngoutput2 as single
    dim sngoutput3 as single

    snginput1=val(textbox1.text)
    sngInput2=val(textbox2.text)
    snginput3=val(textbox3.text)
    snginput5=val(textbox5.text)
    snginput6=val(textbox6.text)
    snginput1=val(textbox8.text)
    snginput1=val(textbox9.text)


    sngOutput1=sngInput1-sngInput2+sngInput3
    Label1.text=sngOutput1


    sngOutput2=snginput4 - snginput5 + snginput6
    Label2.text=sngoutput2

    sngoutput3=snginput7 - snginput8 +snginput9
    Lbel3.text=sngoutput3

    I would use a single data type b/c I dont know how big or small the numbers the users are inputing are.
    I would also use labels for the output numbers b/c i dont see any reason why they need to be textboxes since the user is not inputing anything into them.
    If you want the code to execute when the textchanges just copy and paste the code for the given equation in each of the 2 or 3 textboxes that are in the formulas...
    hope this helped

    DDT
    “The sky above the port was the color of television, tuned to a dead channel.”

  3. #3
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    See if this helps. As you enter text into the boxes, it dynamically updates the left hand rows.
    Attached Files Attached Files

  4. #4
    Member
    Join Date
    Sep 2003
    Posts
    40
    Well, i'm not anywhere near intermediate or expert, but a mch shorter piece of code would be...
    ---

    textbox4.text = val(textbox1.text) - val(textbox2.text) + val(textbox3.text)

    textbox7.text = val(textbox4.text) - val(textbox5.text) + val(textbox6.text)

    textbox10.text = val(textbox7.text) - val(textbox8.text) + val(textbox9.text)

    ---
    u can make a button and double click it, then add that code.

    i realize this isn't an advanced way of doing things, but this question is coming from a beginner who probably wants to learn just one thing at a time.

    Ideally, indeed the output should be in labels, and the input should be in numeric updowns

    hope this helps

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Dec 2003
    Posts
    127

    You guys rock

    Andy thanks for the project files, both you and ramezb84 hit the nail on the head with what I was trying to do with the program I am working on. I didn't want to let it out but I guess among other programmers it's safe to say what your working on. It's a program to help those like me that have a problem balancing their check book.

    The code works perfect and now I have the rest of the day to work out the rest of the program. Your contributions helped me understand more about VB and that's what I needed.

    Here's the link to my other program that I mentioned I had made. Shoot me an email and i'll reply with the link to a free copy of it.

    http://webpages.charter.net/teamdad


    Thanks again,

  6. #6
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    glad you liked it!! just keep in mind that programming a math application is NOT rocket science. Simply sit down and write out what the program is to do ultimately, and work backwards. As you progress with it, you'll find corners you can cut and round out your app to a nice smooth finish.

    You picked a good place to come and learn!!

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