[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
in the upper-left corner of the page.