extract decimal component of number

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

Hi, I need to be able to seperate a number into two components, its decimal
and non decimal component.

For example:
Long Price = 108100
ModifiedPrice= Price/1000 (ie. 108.100)

I need to store these value in two different varibales
numbercomponent = ? (108)
decimalcomponent= ? (.100)

Thank you
 
Hope this helps...

Sub test()
Dim numbercomponent, decimalcomponent, longprice, modifiedprice

longprice = Range("A1").Value
modifiedprice = longprice / 1000
numbercomponent = Int(modifiedprice)
decimalcomponent = modifiedprice - numbercomponent

MsgBox "Numbercomponent = " & numbercomponent & vbNewLine &
"Decimalcomponent = " & decimalcomponent
End Sub


Thanks,

Yogendra
 
LongPrice = 108100
msgbox left(longPrice,len(longPrice)-3) & " - " & right(LongPrice,3)
 

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