Actually i format this rs1 with:
Format(RS1.Fields(7).Value, "#,##0.00")
if the value of rs1 is 0 i have 0,00
but i need this new format:
000.000,00
how to?
special format number
-
- gamma jay
- Posts: 25455
- Joined: 17 Mar 2010, 17:33
- Location: Cape Town
Re: special format number
You could try using an IF statement.
If RS1.Fields(7).Value > 0 then
Format(RS1.Fields(7).Value, "#,##0.00")
ElseIf RS1.Fields(7).Value = 0
Format(RS1.Fields(7).Value, "000,000.00")
End If
If RS1.Fields(7).Value > 0 then
Format(RS1.Fields(7).Value, "#,##0.00")
ElseIf RS1.Fields(7).Value = 0
Format(RS1.Fields(7).Value, "000,000.00")
End If
Regards,
Rudi
If your absence does not affect them, your presence didn't matter.
Rudi
If your absence does not affect them, your presence didn't matter.
-
- Administrator
- Posts: 78420
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: special format number
Or even
Code: Select all
If RS1.Fields(7).Value > 0 then
MyVar = Format(RS1.Fields(7).Value, "#,##0.00")
ElseIf RS1.Fields(7).Value = 0
MyVar = "000,000.00"
End If
Best wishes,
Hans
Hans
-
- 5StarLounger
- Posts: 1098
- Joined: 21 Jan 2011, 16:51
- Location: Florida
Re: special format number
What Office application is this in? If Excel, you can skip all the If statements and apply custom formatting directly to the cell.
The Excel custom format is capable of applying formatting based on values <0, >0 and =0.
From Excel's Help:
which will use your format for any positive number and the string "000,000.00" for any cell = 0.
The Excel custom format is capable of applying formatting based on values <0, >0 and =0.
From Excel's Help:
If you're trying to format data in VBA for a cell in Excel, let Excel do the formatting with the custom format of:A number format can have up to four sections of code, separated by semicolons. These code sections define the format for positive numbers, negative numbers, zero values, and text, in that order.
<POSITIVE>;<NEGATIVE>;<ZERO>;<TEXT>
Code: Select all
#,##0.00;;"000,000.00"
PJ in (usually sunny) FL