none
Add TextBox in Msg form

    Question

  • 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

    Friday, January 11, 2013 6:21 PM

Answers

  • 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!

    Friday, January 11, 2013 8:43 PM

All replies

  • 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 6:54 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 Sub

    I 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:23 PM
  • 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!

    Friday, January 11, 2013 8:43 PM