ArcObjects Library Reference  (System)    

ScientificFormat Example

  1. Copy the code below.
  2. In ArcMap, select Macros... from Tools | Macros (or press Alt-F8).
  3. Enter a new macro name and click the Create button.
  4. Paste the copied code into the code pane.
  5. Press F5 to run the macro.
[Visual Basic 6.0]
Sub ScientificFormatExample() ' Create a ScientificFormat object and set ScientificFormat ' options through the IScientificNumberFormat interface Dim pScientificFormat As IScientificNumberFormat Set pScientificFormat = New ScientificFormat With pScientificFormat .DecimalPlaces = 2 '1 less than the number of significant digits End With ' ValueToString & StringToValue methods are in the ' INumberFormat interface. QI for INumberFormat ' to use them. Dim pNumberFormat As INumberFormat Set pNumberFormat = pScientificFormat ' Format a value Dim dValue As Double, sV2S As String, dS2V As Double dValue = 1500 ' ValueToString() returns a formatted string, but ' does not change the passed in numerical value sV2S = pNumberFormat.ValueToString(dValue) ' StringToValue() translates formatted ' strings back to their original value dS2V = pNumberFormat.StringToValue(sV2S) MsgBox "ValueToString(" & dValue & ") = '" & sV2S & "'" & vbNewLine & _ "StringToValue('" & sV2S & "') = " & dS2V, , _ "ScientificFormat" End Sub

[Visual Basic .NET, C#, C++]
No example is available for Visual Basic .NET, C#, or C++. To view a Visual Basic 6.0 example, click the Language Filter button Language Filter in the upper-left corner of the page.