RealToString Method (ActiveX)

Converts a real (double) value to a string.

Supported platforms: Windows only

Signature

VBA:

RetVal = object.RealToString(Value, Unit, Precision)
object

Type: Utility

The object this method applies to.

Value

Access: Input-only

Type: Double

The value to be converted.

Unit

Access: Input-only

Type: AcUnits enum

  • acDefaultUnits
  • acScientific
  • acDecimal
  • acEngineering
  • acArchitectural
  • acFractional
Precision

Access: Input-only

Type: Long

The precision of the value. An integer between 0 and 8.

Return Value (RetVal)

Type: String

The value as a properly formatted string.

Remarks

No additional remarks.

Examples

VBA:

Sub Example_RealToString()
    ' This example converts values in a given format to their string equivalents.
    
    Dim unit As Long
    Dim valueAsStr As String
    Dim precision As Integer
    Dim valueAsReal As Double
    precision = 6
    
    ' Convert a real value 17.5 using Scientific mode to a String
    unit = acScientific
    valueAsStr = ThisDrawing.Utility.RealToString(17.5, unit, precision)
    MsgBox "17.5 in scientific format is " & valueAsStr, , "RealToString Example"
    
    ' Convert a real value 17.5 using Decimal mode to a String
    unit = acDecimal
    valueAsStr = ThisDrawing.Utility.RealToString(17.5, unit, precision)
    MsgBox "17.5 in decimal format is " & valueAsStr, , "RealToString Example"
    
    ' Convert a real value 17.5 using Engineering mode to a String
    unit = acEngineering
    valueAsStr = ThisDrawing.Utility.RealToString(17.5, unit, precision)
    MsgBox "17.5 in engineering format is " & valueAsStr, , "RealToString Example"
    
    ' Convert a real value 17.5 using Architectural mode to a String
    unit = acArchitectural
    valueAsStr = ThisDrawing.Utility.RealToString(17.5, unit, precision)
    MsgBox "17.5 in architectural format is " & valueAsStr, , "RealToString Example"
    
    ' Converts a real value 17.5 using fractional mode to a String
    unit = acFractional
    valueAsStr = ThisDrawing.Utility.RealToString(17.5, unit, precision)
    MsgBox "17.5 in fractional format is " & valueAsStr, , "RealToString Example"
    
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_RealToString()
    ;; This example converts values in a given format to their string equivalents.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
  
    (setq precision 6)
    
    ;; Convert a real value 17.5 using Scientific mode to a String
    (setq valueAsStr (vla-RealToString (vla-get-Utility doc) 17.5 acScientific precision))
    (alert (strcat "17.5 in scientific format is " valueAsStr))
    
    ;; Convert a real value 17.5 using Decimal mode to a String
    (setq valueAsStr (vla-RealToString (vla-get-Utility doc) 17.5 acDecimal precision))
    (alert (strcat "17.5 in decimal format is " valueAsStr))
    
    ;; Convert a real value 17.5 using Engineering mode to a String
    (setq valueAsStr (vla-RealToString (vla-get-Utility doc) 17.5 acEngineering precision))
    (alert (strcat "17.5 in engineering format is " valueAsStr))
    
    ;; Convert a real value 17.5 using Architectural mode to a String
    (setq valueAsStr (vla-RealToString (vla-get-Utility doc) 17.5 acArchitectural precision))
    (alert (strcat "17.5 in architectural format is " valueAsStr))
    
    ;; Converts a real value 17.5 using fractional mode to a String
    (setq valueAsStr (vla-RealToString (vla-get-Utility doc) 17.5 acFractional precision))
    (alert (strcat "17.5 in fractional format is " valueAsStr))
)