Displaying a decimal with 2 decimal places (ie currency!)

S

Scott

I want to display a decimal as a currency value for instance £65.00 or £58.47, but at the moment the code doesn't seem to work correctly. Can I declare this variable to be shown with 2 decimal places any easier??? Maybe at the start of the program?? Here is my code...

o65 = CType(o65, Decimal).ToString("C")

win17 = CType(win17, Decimal).ToString("C")

total = CType(total, Decimal).ToString("C")

total = price + o65 + win17

TextBox6.Text = "The Total price for your trip is £" & total

thanks a lot

Scott
 
H

Herfried K. Wagner [MVP]

Scott said:
I want to display a decimal as a currency value for instance £65.00 or
£58.47, but at the moment the code doesn't seem to work correctly. Can I
declare this variable to be shown with 2 decimal places any easier???
Maybe at the start of the program?? Here is my code...

o65 = CType(o65, Decimal).ToString("C")

win17 = CType(win17, Decimal).ToString("C")

total = CType(total, Decimal).ToString("C")

total = price + o65 + win17

TextBox6.Text = "The Total price for your trip is £" & total

\\\
Dim o65 As Decimal = 22.222D
Dim win17 As Decimal = 234.3434D
Dim total As Decimal = o65 + win17
Me.Text = "The Total price for your trip is " & total.ToString("C2")
///
 
C

chanmmn

You should not convert to string before you add them.

chanmm
I want to display a decimal as a currency value for instance £65.00 or £58.47, but at the moment the code doesn't seem to work correctly. Can I declare this variable to be shown with 2 decimal places any easier??? Maybe at the start of the program?? Here is my code...

o65 = CType(o65, Decimal).ToString("C")

win17 = CType(win17, Decimal).ToString("C")

total = CType(total, Decimal).ToString("C")

total = price + o65 + win17

TextBox6.Text = "The Total price for your trip is £" & total

thanks a lot

Scott
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top