Is it possible to set the formatting of a number to display, for example, 10 1/2 (and 1/2 is written in "normal" style, you know, 1 over 2 in smaller font) as opposed to 10.5?
Printable View
Is it possible to set the formatting of a number to display, for example, 10 1/2 (and 1/2 is written in "normal" style, you know, 1 over 2 in smaller font) as opposed to 10.5?
I seriously doubt it since what you're asking for is NOT a font but a whole parsing algorithm. It's possible that someone has subclassed a font to do that work behind the scenes but it would be so inherently limited that it's just as likely that no one has bothered. Figuring out how to construct a web search for what you want would be an interesting exercise all by itself. good luck.
It is possible, however some parsing will definately be involved. You will need to find a decimal point which isn't the same in different parts of this world, then you will nedd identify if it is a half (may be some rounding routine is necessary) and only when it is finally identified as "ONE HALF" you may use Replace function (in VB6 only otherwise Mid) to replace what's after decimal point with ASCII charachter 189 [Chr(189); True fonts only] . Is it worth it - I don't think so!
Roy
You could convert 10.5 to 10 1/2 fairly easily. And most fonts have the 1/2 symbol.
If 1/2 is the ONLY fraction you want then it's easy. My reply was based on the assumption (apparently not shared by the other respondents) that you want a generic solution, not just for the particular example of 1/2
What you'd do to get a fraction from the decimal is this:
Convert the decimal number to a non-decimal number, store the value needed to do this.
Then it's number/store value. to do this you're going to have to see how many of the stored values * x = big number without going over. then subtract the number by that value. Then reduce the fraction by checking the number and the stored number for like multiples.
Yes, I am looking for 1/2 only.
½
there's also
¼¾
you could do:
if right("10.5",2) = ".5" then msgbox replace("10.5",".5","½")
That looks like what I need. How do you get the fraction to replace .5 as opposed to 1/2?
waht do you mean?
If instr(num,".5") > 0 then num = replace(num, ".5", " 1/2")
Sorry...I want to use the "normal" looking fraction (1 over 2, and a smaller font...as you did in your previous posting) as opposed to "1/2". I could live with either way, I was just wondering how to do it.
So replace my 1/2 with a copy/paste of the other 1/2.
i already gave you the way to do it:
if right("10.5",2) = ".5" then msgbox replace("10.5",".5","½")
Actually, just get the length of the string to the right of the decimal place, and put that over 10^(Len). Then write a simplify function. Simple really.
What character code is that li'l "1/2" that you put in there?
Doesn'y anybody read? It says in one of the first few posts that ASCII 189 is the ½ character... :rolleyes:
Quote:
ASCII charachter 189 [Chr(189); True fonts only]
lol... missed it, thanks ;)