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 :D :P :duck:
Printable View
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 :D :P :duck:
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
i made an extremely simple calculator in the codebank, under 20 lines of code and actually looks/works like a 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:
Private Sub Command1_Click() If Text1.Text = 2 Then Label1.Caption = Val(83) - Val(Text2.Text) / 4.5 Else MsgBox ("Meh...") End Else End Sub
End Else should be End If :)
lol omfg, but i changed it and it still doesn't work... what now?
I don't think I fully understand the problem... The label always shows 83? :ehh:
yup :D tht is the problem
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...
nope, even with text in it, it still just shows 83
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
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...
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
thnx dude, this is what i put : "((83 - val(text2)) / 4.5)" and it worked... thnx man!