ArcObjects Library Reference  (System)    

RateFormat 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 RateFormatExample() ' Create a RateFormat object and set RateFormat ' options through the IRateFormat interface Dim pRateFormat As IRateFormat Set pRateFormat = New RateFormat With pRateFormat .RateFactor = 1000 .RateString = " kilotons" End With ' Set NumericFormat options through the INumericFormat interface. ' This step is not necessary unless you want to change the ' INumericFormat default properties. Comment this block of ' code out to see how it changes the format! Dim pNumericFormat As INumericFormat Set pNumericFormat = pRateFormat With pNumericFormat .AlignmentOption = esriAlignRight .RoundingOption = esriRoundNumberOfDecimals .AlignmentWidth = 16 .RoundingValue = 5 .ShowPlusSign = True .UseSeparator = True .ZeroPad = False End With ' The ValueToString & StringToValue methods are in the ' INumberFormat interface. QI for INumberFormat to ' use them. Dim pNumberFormat As INumberFormat Set pNumberFormat = pRateFormat '= pNumericFormat could be used here as well ' Format some values Dim dValue As Double, sV2S As String, dS2V As Double For dValue = 0 To 1000000 Step 250000 sV2S = pNumberFormat.ValueToString(dValue) dS2V = pNumberFormat.StringToValue(sV2S) MsgBox "ValueToString(" & dValue & ") = '" & sV2S & "'" & vbNewLine & _ "StringToValue('" & sV2S & "') = " & dS2V, , _ "RateFormat - RateFactor = " & pRateFormat.RateFactor Next ' Change RateFactor and show it again pRateFormat.RateFactor = 1 pRateFormat.RateString = " tons" For dValue = 0 To 1000000 Step 250000 sV2S = pNumberFormat.ValueToString(dValue) dS2V = pNumberFormat.StringToValue(sV2S) MsgBox "ValueToString(" & dValue & ") = '" & sV2S & "'" & vbNewLine & _ "StringToValue('" & sV2S & "') = " & dS2V, , _ "RateFormat - RateFactor = " & pRateFormat.RateFactor Next 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.