I need Help in a form

X

Xispo

I am trying to make a simple form calculator!

2 Textboxes, and then when I click a button another textbox display
the sum of the 2 textboxes.

How do I do this? Does the answer need to appear in a label o
textbox?

I think I need to have a button so that the form refreshes and I ge
the answer, is this the case??

thank
 
E

Edwin Tam (MS MVP)

1) In VBA Editor, insert a new UserForm to your project
2) On the userform, place two text boxes. (Their names are "TextBox1" and "TextBox2" for example)
3) Place one Label. (It name is "Label1" for example)
4) Place one command button (It name is "CommandButton1" for example)
5) Double-click the command button to insert some code

Private Sub CommandButton1_Click()
Label1.Caption = TextBox1.Value + TextBox2.Value
End Sub


----- Xispo wrote: -----


I am trying to make a simple form calculator!

2 Textboxes, and then when I click a button another textbox displays
the sum of the 2 textboxes.

How do I do this? Does the answer need to appear in a label or
textbox?

I think I need to have a button so that the form refreshes and I get
the answer, is this the case??

thanks
 
X

Xispo

Thanks for that, it almost worked, but if I put 1 in a box and 2 in th
other, it give 12, ie it is joinging them not mathematically addin
them, how do I fix this?

thank
 
E

Edwin Tam (MS MVP)

Try

Private Sub CommandButton1_Click(
Label1.Caption = Val(TextBox1.Text) + Val(TextBox2.Value
End Su

----- Xispo wrote: ----


Thanks for that, it almost worked, but if I put 1 in a box and 2 in th
other, it give 12, ie it is joinging them not mathematically addin
them, how do I fix this

thank
 

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

Top