Examples: CCur function

Example 1

' Convert string to currency
' Display value and data type
Dim nvar As Variant
Dim nstr As String
nstr = Inputbox("Number", "Enter any number", "0")
If Isnumeric(nstr) Then
	nvar = Ccur(nstr)
	Messagebox nvar,, Typename(nvar)
Else
	Messagebox nstr,, "Not a number"
End Sub

Example 2

Dim bulkPrice As Double
Dim labelPrice As String
Dim unitsSold As Integer
Dim paymentDue As Currency
bulkPrice# = 11.400556
unitsSold% = 57
paymentDue@ = CCur(bulkPrice# * unitsSold%)
Print paymentDue@               ' Prints 649.8317
labelPrice$ = "12.99"
paymentDue@ = CCur(labelPrice$) * unitsSold%
Print paymentDue@               ' Prints 740.43