Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display numbers right of decimal

Status
Not open for further replies.

M626

Programmer
Mar 13, 2002
299
0
0
I need to retreive number right of the decimal place.

example: 7.45
I need to get .45 and display it in text box.

Can anyone help?
 
Try:

MyNumber = 7.45
MyTextBox.text = right(str(MyNumber), 3)

Hope this helps,
Ralph
 
CCLINT, ever come across this before? I just tried your method and got quite a strange result.

debug.print 8.97 - int(8.97)

gave me this:

0.970000000000001


Any ideas?

Matt
 
Try:

Test = 7.45
Text1.Text = Mid(Test, InStrRev(Test, ".")) Swi
 
CCLINT's version will work with almost any number / decimal places.

RalphBrowns will only work with 2 dp exactly with no trailing zeroes. If you try with 7.10 you will get 7.1 Let me know if this helps

Check out FAQ222-2244
'There are 10 kinds of people in the world: those who understand binary, and those who don't.'
 
MatDavies
When calculating floating-point numbers you may run into these problems.

Debug.Print CCur(8.97) - Int(8.97)

will be as expected: return 0.97
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top