Results 1 to 14 of 14

Thread: Calculator

  1. #1

    Thread Starter
    Lively Member smart_phil_dude1's Avatar
    Join Date
    Jun 2005
    Location
    Behind You!
    Posts
    125

    Talking Calculator

    How can i make a calculator, like it does a certain number minus a number from a textbox, then divided by another number?



    thnx in advance :P
    Please Help Us Save Ana or donate now by going to Oneana.com

    Visit my Website at http://www.therealfantasy.com

  2. #2
    Banned ThaRubby's Avatar
    Join Date
    Apr 2005
    Location
    127.0.0.1
    Posts
    356

    Re: Calculator

    That is a broad question. You should have tried to make it, and asked us when you were stuck . Here is some examples of calculators. http://pscode.com/vb/scripts/BrowseC...1=Quick+Search

  3. #3
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Calculator

    i made an extremely simple calculator in the codebank, under 20 lines of code and actually looks/works like a calculator

  4. #4

    Thread Starter
    Lively Member smart_phil_dude1's Avatar
    Join Date
    Jun 2005
    Location
    Behind You!
    Posts
    125

    Wink Re: Calculator

    well, this is what i end up with, and it still doesn't work! It Pretends that " - Val(Text2.Text) / 4.5" isn't there... can anyone help me?
    VB Code:
    1. Private Sub Command1_Click()
    2. If Text1.Text = 2 Then
    3. Label1.Caption = Val(83) - Val(Text2.Text) / 4.5
    4. Else
    5. MsgBox ("Meh...")
    6. End Else
    7. End Sub
    Please Help Us Save Ana or donate now by going to Oneana.com

    Visit my Website at http://www.therealfantasy.com

  5. #5
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Calculator

    End Else should be End If


    Has someone helped you? Then you can Rate their helpful post.

  6. #6

    Thread Starter
    Lively Member smart_phil_dude1's Avatar
    Join Date
    Jun 2005
    Location
    Behind You!
    Posts
    125

    Re: Calculator

    lol omfg, but i changed it and it still doesn't work... what now?
    Please Help Us Save Ana or donate now by going to Oneana.com

    Visit my Website at http://www.therealfantasy.com

  7. #7
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Calculator

    I don't think I fully understand the problem... The label always shows 83?


    Has someone helped you? Then you can Rate their helpful post.

  8. #8

    Thread Starter
    Lively Member smart_phil_dude1's Avatar
    Join Date
    Jun 2005
    Location
    Behind You!
    Posts
    125

    Re: Calculator

    yup tht is the problem
    Please Help Us Save Ana or donate now by going to Oneana.com

    Visit my Website at http://www.therealfantasy.com

  9. #9
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Calculator

    Does text2 have something in? If text2 is empty, the Val function will return 0 and 0/4.5 is 0. 83-0 is 83...


    Has someone helped you? Then you can Rate their helpful post.

  10. #10

    Thread Starter
    Lively Member smart_phil_dude1's Avatar
    Join Date
    Jun 2005
    Location
    Behind You!
    Posts
    125

    Re: Calculator

    nope, even with text in it, it still just shows 83
    Please Help Us Save Ana or donate now by going to Oneana.com

    Visit my Website at http://www.therealfantasy.com

  11. #11
    Addicted Member
    Join Date
    May 2005
    Posts
    168

    Re: Calculator

    Hi,

    Smart_Phil_dude:

    Using your example: I entered 2 in text1, 9 in text2, and I got a result of 81 in label1. It looks like it is working to me there must be something happening elsewhere in your code.

    Please note that for your example to change label1 text1 always has to have a 2 in it.

    Have a good one!
    BK

  12. #12

    Thread Starter
    Lively Member smart_phil_dude1's Avatar
    Join Date
    Jun 2005
    Location
    Behind You!
    Posts
    125

    Re: Calculator

    hmm... but it doesn't do the part "- Val(Text2.text) / 4.5"... it doesn't want to substract the amount in Text2, then divided by 4.5...
    Please Help Us Save Ana or donate now by going to Oneana.com

    Visit my Website at http://www.therealfantasy.com

  13. #13
    Addicted Member
    Join Date
    May 2005
    Posts
    168

    Re: Calculator

    Hi,

    smart_phil_dude:

    According to the order of operations the division will be perfomed first so as in my example of using 9 in text2.

    83 - 9 / 4.5
    83 - 2
    81

    if you want the subtraction to be done first then divided use parentheses around subtraction:

    (83 - val(text2)) / 4.5

    Have a good one!
    BK

  14. #14

    Thread Starter
    Lively Member smart_phil_dude1's Avatar
    Join Date
    Jun 2005
    Location
    Behind You!
    Posts
    125

    Re: Calculator

    thnx dude, this is what i put : "((83 - val(text2)) / 4.5)" and it worked... thnx man!
    Please Help Us Save Ana or donate now by going to Oneana.com

    Visit my Website at http://www.therealfantasy.com

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