Imports System
'---------------------------------------------------------
' Description:
' Demonstrates how to represent and display currency
' values in VB.NET using Decimal and formatting.
'---------------------------------------------------------
Module CurrencyExample
Sub Main()
' Price and tax rate
Dim price As Decimal = 199.99D
Dim taxRate As Decimal = 0.17D ' 17%
' Calculate tax and total
Dim taxAmount As Decimal = price * taxRate
Dim total As Decimal = price + taxAmount
' Output with $ and % signs
Console.WriteLine("Price: " & price.ToString("C"))
Console.WriteLine("Tax Rate: 17%")
Console.WriteLine("Tax Amount: " & taxAmount.ToString("C"))
Console.WriteLine("Total: " & total.ToString("C"))
End Sub
End Module
' run:
'
' Price: $199.99
' Tax Rate: 17%
' Tax Amount: $34.00
' Total: $233.99
'