Consulting

Results 1 to 3 of 3

Thread: Solved: Add Caption problem

  1. #1
    VBAX Expert
    Joined
    Apr 2007
    Location
    Orlando, FL
    Posts
    751
    Location

    Solved: Add Caption problem

    I have the following vb Line that is giving me an error when caption is "".

    [VBA]
    LblPrice.Caption = Format(CDbl(LblPrice1.Caption) + CDbl(LblPrice2.Caption) + CDbl(LblPrice3.Caption), "$#,##0.00")

    [/VBA]

    What do I need to do for it to give me the sum even if 1 or more caption's are "" ?

  2. #2
    VBAX Expert JP2112's Avatar
    Joined
    Oct 2008
    Location
    Astoria, NY
    Posts
    590
    Location
    Wrap each one in an IIf statement, like this:

    [VBA]IIf(Len(LblPrice1.Caption)=0,0,LblPrice1.Caption)[/VBA]

    Do this for LblPrice2 and LblPrice3 as well.
    Regards,
    JP

    Read the FAQ
    Getting free help on the web
    My website
    Please use [vba][/vba] tags when posting code

  3. #3
    VBAX Expert
    Joined
    Apr 2007
    Location
    Orlando, FL
    Posts
    751
    Location
    Looks good, Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •