You don't see overloaded operators used that much in custom code. And, in few business applications have I seen a request for fractions, but there was such a request made of me recently. Following a search on the web. I discovered news groups and Q&A sites where some of you did request a Fraction's class. So, I thought I'd share a solution.
In this article, you will learn how to implement a Fraction's class—which is ideally suited for overloaded operators, how to overload operators in Visual Basic, and get a quick reminder from your college days on the Euclidean algorithm for calculating the greatest common divisor.
To complete a Fraction class and make it generally useful, you also want to support basic arithmetic operations on fractions and mixed arithmetic on fractions and decimal (or double) numbers. All of these elements are described in the remainder of this article with a complete code listing at the end of the article.
You can start anywhere, but logically people in the West are oriented to reading from left to right, so that's where you will start. Assuming you have a decimal (double or single) number or a string representing the same, you can strip and store the sign of the number. The following fragment uses a Regular Expression to determine whether a string—you can easily convert numeric strings to and from a string or numeric representation—contains a negative sign and then you store the sign as an integer—1 or -1.
The Regular Expressions "^-" simply checks for a  symbol at the beginning of the input string.
The whole number is as easy to store as the minus sign. You could convert the string to an integer that would do the job for you. You could use Math.Abs to get the number as an absolute value (because you stored the sign), or you could extract the substring, from left to right, up to the index of the decimal point. The latter is the technique demonstrated in the SetWholePart method that will be added to the Fraction class.
The index of the decimal point is returned from the CheckNoDecimalPoint method, shown next.
The easy work is done. Next, you need to find the numerator (and denominator) from the mantissa or the decimal (or fractional) part of the number. The answer is simple: The decimal number without the decimal point is the numerator. For example, 3.2 has a mantissa of .2. The mantissa .2 is 2/10ths, so clearly the mantissa reveals the numerator of the fraction.
The method SetFractionalPart orchestrates setting the numerator and denominator by stripping the mantissa from your input value.
SetFractionalPart clearly shows that you Remove all of the input value up to and including the decimal point and then convert the remaining digits to the numerator store as an integer.