RE: What does the semi-colon do in vba code?

Discussion in 'Access VBA Modules' started by OssieMac, Nov 9, 2009.

  1. OssieMac

    OssieMac Guest

    Hi Russell,

    The semicolon is not so much a concatenation character as a delimiter
    between values and when used with debug.print that is exactly what it does.
    It is similar to multiple Debug.print commands except it does not insert a
    line feed.

    Try using a a comma in lieu of the semicolon and it is more like a tab.
    (extra space)

    However, the ampersand joins all of the strings into one string and can be
    used in code to join several strings and then address them as one string.

    Example using your parameters.
    strConcatenated = "The list box contains " & intNumColumns &
    IIf(intNumColumns _
    = 1, " column", " columns") & " of data."

    Debug.Print strConcatenated

    Now some more info on your example.

    intNumColumns = 1

    This is actually +1 and the leading space produced is actually the missing +
    sign. You can't enter the + sign in your code because VBA intellisence
    removes it but try using -1 in lieu of 1 and run the code again and you will
    see what I mean.


    --
    Regards,

    OssieMac
     
    OssieMac, Nov 9, 2009
    #1
    1. Advertisements

  2. OssieMac

    Sir Joe Guest

    On Monday, 9 November 2009 05:54:01 UTC+1, OssieMac wrote:

    > Try using a a comma in lieu of the semicolon and it is more like a tab.
    > (extra space)


    thanks! this worked very well for me!
    Sir Joe
     
    Sir Joe, Sep 4, 2012
    #2
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.