String Format: Currency : String Format « Development « VB.Net






String Format: Currency

String Format: Currency
  
Imports System

Public Class MainClass

    Shared Sub Main(ByVal args As String())

      Dim amount, principal As Decimal ' dollar amounts
      Dim rate As Double               ' interest rate
      Dim year As Integer              ' year counter
      Dim output As String             ' amount after each year

      principal = 1000
      rate = 0.05

      output = "Year" & vbTab & "Amount on deposit" & vbCrLf

      ' calculate amount after each year
      For year = 1 To 10
         amount = principal * (1 + rate) ^ year
         output &= year & vbTab & _
            String.Format("{0:C}", amount) & vbCrLf
      Next

      ' display output
      Console.WriteLine("Compound Interest" & output)

    End Sub
    

End Class

           
         
    
  








Related examples in the same category

1.Double number format: 0:n3Double number format: 0:n3
2.Proper Title Case
3.Assume en-US culture and standard format string
4.Format a string with composite string