Select the product you need help with
- Internet Explorer
- Windows Phone
- More products
How To Display a Number as a Fraction
Article ID: 185479 - View products that this article applies to.
This article was previously published under Q185479
This article provides three routines to convert a decimal fraction to the form "a b/c".
Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs.
If you have limited programming experience, you may want to contact a Microsoft Certified Partner or Microsoft Advisory Services. For more information, visit these Microsoft Web sites:
Microsoft Certified Partners - https://partner.microsoft.com/global/30000104
Microsoft Advisory Services - http://support.microsoft.com/gp/advisoryservice
For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS
(http://support.microsoft.com/default.aspx?scid=fh;en-us;cntactms)In many instances, it is useful to be able to output a decimal value as a fraction in the form "a/b" or "a b/c". This article provides three routines that perform that function.
A normalized fraction contains the smallest possible denominator. The GCF() function (Greatest Common Factor) is used in the normalization process.
Function Description -------- ----------- Frac2Num Returns a normalized fraction with the denominator in the range of 2..8. Frac2NumA Returns a non-normalized fraction with the denominator you specify. Frac2NumB Returns a normalized fraction based on a denominator you specify.
Non-normalized : 4/6
Normalized : 2/3
For more information about getting help with Visual Basic for Applications, please see the following article in the Microsoft Knowledge Base:
(http://support.microsoft.com/kb/163435/EN-US/ )VBA: Programming Resources for Visual Basic for Applications
Article ID: 185479 - Last Review: November 23, 2006 - Revision: 2.3