|
-
Aug 13th, 2002, 02:02 PM
#1
Thread Starter
Member
Number formatting (0.5 -> 1/2)
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?
-
Aug 13th, 2002, 02:14 PM
#2
PowerPoster
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.
-
Aug 13th, 2002, 04:03 PM
#3
PowerPoster
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
-
Aug 13th, 2002, 04:05 PM
#4
So Unbanned
You could convert 10.5 to 10 1/2 fairly easily. And most fonts have the 1/2 symbol.
-
Aug 13th, 2002, 04:08 PM
#5
PowerPoster
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
-
Aug 13th, 2002, 04:12 PM
#6
So Unbanned
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.
-
Aug 13th, 2002, 04:12 PM
#7
Thread Starter
Member
Yes, I am looking for 1/2 only.
-
Aug 13th, 2002, 04:17 PM
#8
The picture isn't missing
½
there's also
¼¾
you could do:
if right("10.5",2) = ".5" then msgbox replace("10.5",".5","½")
Remember, if someone's post was not helpful, you can always rate their post negatively  .
-
Aug 13th, 2002, 04:26 PM
#9
Thread Starter
Member
That looks like what I need. How do you get the fraction to replace .5 as opposed to 1/2?
-
Aug 13th, 2002, 04:28 PM
#10
The picture isn't missing
Remember, if someone's post was not helpful, you can always rate their post negatively  .
-
Aug 13th, 2002, 04:29 PM
#11
So Unbanned
If instr(num,".5") > 0 then num = replace(num, ".5", " 1/2")
-
Aug 13th, 2002, 04:31 PM
#12
Thread Starter
Member
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.
-
Aug 13th, 2002, 04:35 PM
#13
So Unbanned
So replace my 1/2 with a copy/paste of the other 1/2.
-
Aug 13th, 2002, 04:37 PM
#14
The picture isn't missing
i already gave you the way to do it:
if right("10.5",2) = ".5" then msgbox replace("10.5",".5","½")
Remember, if someone's post was not helpful, you can always rate their post negatively  .
-
Aug 13th, 2002, 05:09 PM
#15
Hyperactive Member
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.
-
Aug 13th, 2002, 05:28 PM
#16
Lively Member
What character code is that li'l "1/2" that you put in there?
-
Aug 13th, 2002, 05:36 PM
#17
PowerPoster
Doesn'y anybody read? It says in one of the first few posts that ASCII 189 is the ½ character... 
ASCII charachter 189 [Chr(189); True fonts only]
-
Aug 13th, 2002, 05:53 PM
#18
Lively Member
lol... missed it, thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|