473,386 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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

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

Nov 21 '05 #1
2 3078
"Scott" <sj*****@btinternet.com> schrieb:
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")
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #2
You should not convert to string before you add them.

chanmm
"Scott" <sj*****@btinternet.com> wrote in message news:1B****************@newsfe5-gui.ntli.net...
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

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: BA | last post by:
Hello, I have a string with a price in: "$14.95" I need to get it into a decimal. So I regex 'd the string and dumped the $. Debug mon shows a clean string "14.95" Then I do a...
1
by: John Rebbeck | last post by:
I'm currently using Decimal for my currency data but I noticed it has 4 decimal places (which is wrong when displaying with .ToString()). I either need to format the data correctly when displaying...
6
by: John A Grandy | last post by:
i thought the following would work for currency {0:$000,000,000.00} but it is displaying ( for example ) : $000,025,368.87 i don't want the extra zeros ...
1
by: Les Hughes | last post by:
Hey guys (and gals!), I have a dataset brought back from sqsl server, where some of the columns are already rounded within the dataset (retrieved using SELECT ROUND(data, decimalplaces) as...
6
by: Jim Stools | last post by:
How do I do this: result needs to be a decimal to 2 places? I get casting problems on the below: double myPrice = 1200.125;double myShares = 354.288; decimal myTotal; myTotal = myPrice *...
1
Shashi Sadasivan
by: Shashi Sadasivan | last post by:
hi, im comparing two decimal variables d1,d2. at some points, d1 == d2 (where d1 and d2 = 8 shown in debug mode) turns out as false!!! is this a c/c++ version of comparing floats? any ideas on...
1
by: adigita | last post by:
How to disply decimal part in the grid view of .Net forms ? Example Field Name : ITEM RATE NUMBER(11,4) (ORACLE DATABSE) OUTPUT[ TO BE DISPLAYED AS 1.09 ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.