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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

method to convert fraction to decimal or float

Status
Not open for further replies.

pwomack

Technical User
Apr 16, 2005
121
US
Is there a method to call in vb2005 or vb2008 that will convert a fraction to a decimal or float?

The user will enter a number with a fraction such as: 18 3/8

I then want to convert the value entered to: 18.375

Thanks.
 
Take the whole number and set it aside, then take the fraction and just Divide ( 3 / 8 = Decimal value) then add the two numbers together.

"If I were to wake up with my head sewn to the carpet, I wouldn't be more surprised than I am right now.
 
Thanks. I thought of that, but I'm new to this and I had hoped there was an easier method.
 
There's no built-in method (in VB2005 at least), but you could build your own Fraction class. There are plenty of examples available.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top