Textbox Question

  • Thread starter Thread starter Greg B
  • Start date Start date
G

Greg B

Can someone help me with, I have textbox1 which has a number in it, I want
the user to type in the amount in textbox2 and I want textbox3 to show the
total of tb1 + tb2

How do I do this

Thanks

Greg
 
Hello Greg,

Here's the code...

Dim tbSum

tbSum = Val(TetxBox1.Value) + Val(TextBox2.Value)
TextBox3.Value = tbSum

Sincerely,
Leith Ross
 
Hi,

When you design the userform it would also be a good idea to block the
(output)TextBox3 from any input with
Textbox3.Enabled = False

Then I would put a commandbutton on the screen which first makes a
control of the numeric values in the two (input)textboxes(1 & 2),
if this control is OK then the sum is shown in the outputbox Textbox3,
if it's not OK you get a message...

so I would adjust the code of Leith to this :

Private Sub CommandButton1_Click()

If IsNumeric(Val(TextBox2.Value)) And IsNumeric(Val(TextBox1.Value))
Then
TextBox3.Value = Val(TextBox2.Value) + Val(TextBox1.Value)
Else
MsgBox ("Not a Numeric value")
End If

End Sub


Bye
Baj
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top