Add TextBox in Msg form
-
Friday, January 11, 2013 6:21 PM
This is my first time working with VBA so sorry for the noob question
If I design a form and add a series of txtboxs to the form, how can I add them and show the result in a txtbox?
txtbox01 + txtbox02 + txbox03 = txtbox04
Jason
All Replies
-
Friday, January 11, 2013 6:54 PMModerator
Something like:
Dim lngX As Long lngX = txtbox01.Text + txtbox02.Text txtbox03.Text = lngX
For better code, use the IsNumeric function on each control to ensure you are adding numbers, not text. Or add error handling to handle non-numeric entries.Eric Legault MVP (Outlook)
About me...
Outlook Appins: Store Social Media fields in your Outlook Contacts! -
Friday, January 11, 2013 8:23 PM
I am getting an expected end of statement line no:2
The code
Private Sub TextBox1_Change()
Dim lngX As string
lngX = textbox1.Text + texttbox2.Text
textbox3.Text = lngX
End SubI have not played around with VB in 15 years, VBA never. Sorry for easy questions
Jason
- Edited by freebird_ Friday, January 11, 2013 8:57 PM
-
Friday, January 11, 2013 8:43 PMModerator
Most likely a syntax error. On the menu bar, click Debug -> Compile Project1. This will check your code for basic formatting or syntax errors. You should also add the Option Explicit line to the top of your module to enfore the explicit declaration of variables, which helps you write cleaner code.Eric Legault MVP (Outlook)
About me...
Outlook Appins: Store Social Media fields in your Outlook Contacts!- Marked As Answer by Tom_Xu_WXModerator Tuesday, January 15, 2013 6:33 AM

