473,387 Members | 1,464 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,387 software developers and data experts.

Format(price, "#.0")

Say price = 4179.00 or 4179
In VB6, when I do Format(price, "#.0"), it returns 4179.0, but in VB.NET
when I do String.Format(price, "#.0"), it returns 4179.00.
How can I do Format(price, "#.0") in VB.NET ?
Thank you.
Aug 22 '07 #1
6 3223
"fniles" <fn****@pfmail.comschrieb:
Say price = 4179.00 or 4179
In VB6, when I do Format(price, "#.0"), it returns 4179.0, but in VB.NET
when I do String.Format(price, "#.0"), it returns 4179.00.
How can I do Format(price, "#.0") in VB.NET ?
\\\
MsgBox(Format(price, "#.0"))
///

In this particular case it's the same as in VB6.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Aug 22 '07 #2
"fniles" <fn****@pfmail.comschrieb
Say price = 4179.00 or 4179
In VB6, when I do Format(price, "#.0"), it returns 4179.0, but in
VB.NET when I do String.Format(price, "#.0"), it returns 4179.00.
How can I do Format(price, "#.0") in VB.NET ?
Thank you.
Really
String.Format(price, "#.0")
?

This can not even be compiled. Enable Option Strcit to see these faults
ASAP. Press F1 to get the argument description: The first one must be the
format. The valid formats are described in the help,
too. ..... This one:
http://msdn2.microsoft.com/en-us/library/427bttx3.aspx
Armin

Aug 22 '07 #3
Here is a pretty good article with plenty of examples:

http://blogs.msdn.com/kathykam/archi...29/564426.aspx
"fniles" <fn****@pfmail.comwrote in message
news:es*************@TK2MSFTNGP06.phx.gbl...
Say price = 4179.00 or 4179
In VB6, when I do Format(price, "#.0"), it returns 4179.0, but in VB.NET
when I do String.Format(price, "#.0"), it returns 4179.00.
How can I do Format(price, "#.0") in VB.NET ?
Thank you.


Aug 22 '07 #4
Use the FormatCurrency function

Regards
Steve

"fniles" <fn****@pfmail.comwrote in message
news:es*************@TK2MSFTNGP06.phx.gbl...
Say price = 4179.00 or 4179
In VB6, when I do Format(price, "#.0"), it returns 4179.0, but in VB.NET
when I do String.Format(price, "#.0"), it returns 4179.00.
How can I do Format(price, "#.0") in VB.NET ?
Thank you.


Aug 22 '07 #5


"fniles" <fn****@pfmail.comwrote in message
news:es*************@TK2MSFTNGP06.phx.gbl...
Say price = 4179.00 or 4179
In VB6, when I do Format(price, "#.0"), it returns 4179.0, but in VB.NET
when I do String.Format(price, "#.0"), it returns 4179.00.
How can I do Format(price, "#.0") in VB.NET ?
Thank you.

You would use String.Format("{0:#.0}", price).

HTH,
Mythran

Aug 28 '07 #6
fniles wrote:
Say price = 4179.00 or 4179
In VB6, when I do Format(price, "#.0"), it returns 4179.0, but in VB.NET
when I do String.Format(price, "#.0"), it returns 4179.00.
How can I do Format(price, "#.0") in VB.NET ?
Thank you.
The format is the first parameter, so you would be using the string
representation if the price as format, and as it doesn't contain any
formatting at all, the second parameter wouldn't be used at all.

Use String.Format("{0:#.0}", price) or price.ToString("#.0").

--
Göran Andersson
_____
http://www.guffa.com
Aug 28 '07 #7

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

Similar topics

6
by: Allan Koch | last post by:
Dear NG, I would like to format a record in a subform, dependent on a value in one field. If one field in the record I show in a subform (datasheet view) is true I like to view that particular...
2
by: Von Shean | last post by:
I use the following code to format the numbers to have commas. But in case when input is zero it returns an empty string....any ideas? String.Format("{0:#,###.##}",dblNum);
3
by: dan | last post by:
I am using VB.NET 2003 and SQL Server 2000. The program uses ADO.NET . The following instruction: Me.cd_insertDataRecord.ExecuteNonQuery() throws this exception: ">>>ProcessDataRecord/...
5
by: Robin Tucker | last post by:
My database has a column for numeric data items. How can I use this number in the "format" command, such that for, say precision 2, I get numbers like 2011.01 or 2387.00 and for 4 I would get...
16
by: Al Reid | last post by:
First, I'm using vb2005. I have a string that is read from a barcode reader into a TextBox. The string is 6 characters long and represents a date (mmddyy). I want to display it to the user in a...
3
by: shill57957 | last post by:
I have a query: SELECT .AH_TICKNO, Format((.AH_AMOUNT-.AH_TRNAMT)/.AH_AMOUNT,"Percent") AS DIF INTO FROM ; I dont want to format as a percent, I want it to go into the table with 4 decimal...
14
by: | last post by:
Hi, I program in asp.net. I have a date in TextBox in format "dd/MM/yyyy". I would like to validate if the date is realy correct. I used RegularExpressionValidator with...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.