Hi I'm new to vb and would like to know the code for doing mathematical equations e.g. adding, multiplying, with textboxes and comboboxes, which saves the answer to a invisible textbox/combobox to be retrieved later
thanks
buzzlightyear :D
Printable View
Hi I'm new to vb and would like to know the code for doing mathematical equations e.g. adding, multiplying, with textboxes and comboboxes, which saves the answer to a invisible textbox/combobox to be retrieved later
thanks
buzzlightyear :D
VB Code:
Private Sub Command1_Click() Text2.Text = Val(Text1.Text) + Val(Combo1.Text) End Sub Private Sub Form_Load() Text2.Visible = False End Sub
I would store the number in a variable though :)
Thanks peet
but how do you place brackets in the code as to make one step before the other. e.g. 2+(4-1) and what is the sign for multiplying and where is it placed
thanks
buzzlightyear
You can do as you have wrote 2+(4-1). ie.
The code follows the same rules of maths... totaling calculations in brackets before calculating the total.Code:Text2.Text = val(Text3.Text) - (Val(Text1.Text) + Val(Combo1.Text))
'or
Text2.Text = 2 + (4 - 1)
and from left to right.Quote:
Originally posted by -=XQ=-
You can do as you have wrote 2+(4-1). ie.
The code follows the same rules of maths... totaling calculations in brackets before calculating the total.Code:Text2.Text = val(Text3.Text) - (Val(Text1.Text) + Val(Combo1.Text))
'or
Text2.Text = 2 + (4 - 1)
The sign for multiplication is the asterisk (*)
VB Code:
z = x * 5 - (3 * y) / 12
Brackets, Or, Division, Multiplication, Addition, Subtraction. The same rule follow for math eqn's in VB