[Visual Basic 6.0]Sub CurrencyFormatExample() ' CurrencyFormat is an INumberFormat Dim pCurrencyFormat As INumberFormat Set pCurrencyFormat = New CurrencyFormat ' Use the ValueToString method to format numbers. ' We don't need to QI because INumberFormat is the ' only interface in CurrencyFormat. Dim dValue As Double, sV2S As String, dS2V As Double For dValue = 100.567 To 1000101 Step 200000 ' ValueToString() returns a formatted string, but ' does not change the passed in numerical value sV2S = pCurrencyFormat.ValueToString(dValue) ' StringToValue() translates formatted ' strings back to a numerical value dS2V = pCurrencyFormat.StringToValue(sV2S) MsgBox "ValueToString(" & dValue & ") = '" & sV2S & "'" & vbNewLine & _ "StringToValue('" & sV2S & "') = " & dS2V, , _ "CurrencyFormat" 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
in the upper-left corner of the page.