Need help with calculating a formula

Posts 15 of 5 · Page 1 of 1
Need help with calculating a formula
Hello mpgh members.

The question that is frustrating me is that I try to solve a math formula in visual basic but it simply won't come on the right answer!
I do not know what I am doing wrong.

As an example of what I am trying to do is the following thing: textbox1.text * 60 - textbox2.text / 60 . so what I mean is(5 * 60 - 15 / 60 = 4.75) But I come at 299.75
I am using the following code:
Code:
Dim i, j, answer As Single

        i = textbox1.Text
        j = textbox2.Text


        answer = i * 60 - j / 60

        Label1.Text = answer
I hope someone can help me!
Use parenthesis, else the "Order of Operations" is used by default.

As an example of what I am trying to do is the following thing: textbox1.text * 60 - textbox2.text / 60 . so what I mean is(5 * 60 - 15 / 60 = 4.75) But I come at 299.75
5 * 60 - 15 / 60
Multiply and Divide occur before subtraction so..
(5 * 60) - (15 / 60) == (300) - (1/4) = 299.75 --- this is with the normal order of operations. Use parenthesis to create your own order..



(5 * 60 - 15) / 60

will result in
(300 - 15) / 60

(285) / 60
@abuckau907
Thank you so much!
I searched over the internet but simply didn't understand what happend to my calculation that this happend.
Thanks for the explanation and solving my question
No problem, but remember, a book (hard copy or digital) will explain it better : ) if you get to the point where you actually want to learn the Visual Basic language, I highly recommend a book as most ppl on a forum won't answer questions they consider basic...in fact, some people (including myself) will give you a hard time about it (you've been warned lol). Anyway, gl, see you around.
Quote Originally Posted by abuckau907 View Post
No problem, but remember, a book (hard copy or digital) will explain it better : ) if you get to the point where you actually want to learn the Visual Basic language, I highly recommend a book as most ppl on a forum won't answer questions they consider basic...in fact, some people (including myself) will give you a hard time about it (you've been warned lol). Anyway, gl, see you around.
Thankyou I was thinking about to buy a book but I am still searching for a good one.
Posts 15 of 5 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?