ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Textbox Question (https://www.excelbanter.com/excel-programming/344815-textbox-question.html)

Greg B[_6_]

Textbox Question
 
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



Leith Ross[_227_]

Textbox Question
 

Hello Greg,

Here's the code...

Dim tbSum

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

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=482469


baj

Textbox Question
 
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



All times are GMT +1. The time now is 04:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com