1. Login to Give a bone

## formating text strings

I am looking for a way in VBA to round text strings which are in decmial to fractions
example would be 38.875 I would like this to be 38 7/8

Does anyone have any ideas on this or maybe a script to do this ?

Anything would be appricated...

2. Login to Give a bone

## Re: formating text strings

You can use the DistanceToReal function and specify the acFractional enum for the units argument.

3. Login to Give a bone

## Re: formating text strings

can you please send me an example on how i can use this

thanks very much

4. Login to Give a bone

## Re: formating text strings

Originally Posted by rwbaker
can you please send me an example on how i can use this

thanks very much
Code:
```' Convert the distance to a real in fractional units
unit = acFractional
distAsString = "17 1/2"
distAsReal = ThisDrawing.Utility.DistanceToReal(distAsString, unit)
MsgBox "1'-5 1/2"" converts to " & distAsReal & " in fractional units.", , "DistanceToReal Example"```
HTH

5. Login to Give a bone

## Re: formating text strings

ok i am brain dead... guess i am just fighting this one...

how can i go from 17.625 to 17 5/8"

thanks again....

6. Login to Give a bone

## Re: formating text strings

They gave you part of the example out of the help file. You could look there for more info. I was just trying to give you a lead, thinking that you might look it up. But that gives you half the picture, RealToString is the complement. Here is a complete sample.
Code:
```Sub testfract()
' Convert the distance to a real in fractional units
Dim unit As Integer
Dim distAsString As String
Dim distAsReal As Double
Dim NewDist As String
unit = acFractional
distAsString = "17.625"
distAsReal = ThisDrawing.Utility.DistanceToReal(distAsString, unit)
NewDist = ThisDrawing.Utility.RealToString(distAsReal, unit, 3)
Debug.Print "17.625 converts to " & NewDist & " in fractional units."
End Sub```

7. Login to Give a bone

## Re: formating text strings

thanks to all for the help.....

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•