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
Friday, January 11, 2013 6:54 PMModerator
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.
Friday, January 11, 2013 8:23 PM
I am getting an expected end of statement line no:2
Private Sub TextBox1_Change()
Dim lngX As string
lngX = textbox1.Text + texttbox2.Text
textbox3.Text = lngX
I have not played around with VB in 15 years, VBA never. Sorry for easy questions
- Edited by freebird_ Friday, January 11, 2013 8:57 PM
Friday, January 11, 2013 8:43 PMModeratorMost 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.
- Marked As Answer by Tom_Xu_WXModerator Tuesday, January 15, 2013 6:33 AM