PDA

View Full Version : Solved: Add Caption problem



Emoncada
09-01-2011, 09:21 AM
I have the following vb Line that is giving me an error when caption is "".


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



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

JP2112
09-01-2011, 10:11 AM
Wrap each one in an IIf statement, like this:

IIf(Len(LblPrice1.Caption)=0,0,LblPrice1.Caption)

Do this for LblPrice2 and LblPrice3 as well.

Emoncada
09-01-2011, 10:56 AM
Looks good, Thanks