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. 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/>
"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
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.
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.
"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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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);
|
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/...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
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...
| | |