Simple but I can't remember

  • Thread starter Thread starter Andibevan
  • Start date Start date
A

Andibevan

I know this is really forgetful of me but I can't find out what the correct
data type for normal decimal numbers would be e.g. 21.45 or 123.45?

TIA

Andi
 
Double.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 
How do I format something to have 2 decimal places?

The following returns 12.1 not 12.10

Dim lNewRev As Double
lNewRev = 12.1
lNewRev = Format(lNewRev, "###0.00")
Debug.Print lNewRev
 
It sounds like you want to display the value formatted to two decimal places:

Dim lNewRev As Double
Dim lNewRevStr as String
lNewRev = 12.1
lNewRevStr = Format(lNewRev, "###0.00")
Debug.Print lNewRevStr

'or just
debug.print Format(lNewRev, "###0.00")
 
That is because Format returns a string, but you are still using the double.

Try

Dim lNewRev As Double
Dim sFormat As String

lNewRev = 12.1
sFormat = Format(lNewRev, "###0.00")
Debug.Print sFormat

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 

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

Ask a Question

Back
Top