Results 1 to 7 of 7

Thread: formating text strings

  1. #1
    Member
    Join Date
    2004-12
    Posts
    42
    Login to Give a bone
    0

    Default 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...

    thanks in advance

  2. #2
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    5,851
    Login to Give a bone
    0

    Default Re: formating text strings

    You can use the DistanceToReal function and specify the acFractional enum for the units argument.
    C:> ED WORKING....

  3. #3
    Member
    Join Date
    2004-12
    Posts
    42
    Login to Give a bone
    0

    Default Re: formating text strings

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

    thanks very much

  4. #4
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    8,681
    Login to Give a bone
    0

    Default Re: formating text strings

    Quote 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
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  5. #5
    Member
    Join Date
    2004-12
    Posts
    42
    Login to Give a bone
    0

    Default 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. #6
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    5,851
    Login to Give a bone
    0

    Default 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
    C:> ED WORKING....

  7. #7
    Member
    Join Date
    2004-12
    Posts
    42
    Login to Give a bone
    0

    Default Re: formating text strings

    thanks to all for the help.....

Similar Threads

  1. 2014: Change position of 'text formating' dialogue box
    By prowley459709 in forum AutoCAD General
    Replies: 0
    Last Post: 2014-05-28, 05:09 PM
  2. text strings on schedules?
    By timsea81 in forum Revit MEP - General
    Replies: 1
    Last Post: 2009-05-08, 04:30 PM
  3. MText formating - over text
    By Yancka in forum VBA/COM Interop
    Replies: 7
    Last Post: 2009-01-22, 04:42 PM
  4. spell check removes formating of text?
    By Justin Marchiel in forum Revit - Platform
    Replies: 13
    Last Post: 2008-01-16, 06:17 PM
  5. Text strings in Dimensions
    By DaveP in forum Revit Architecture - Wish List
    Replies: 3
    Last Post: 2006-06-26, 12:34 AM

Posting Permissions

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