Hello,
Why does this not work?
txtMoney.Text.Format("#,##0.00")
If I type 100 in txtMoney, it returns #,##0.00
I have never gotten the format function to work in .NET. 10 8168
Hi,
Dim strMoney As String = "12345.34"
Me.Text = CType(strMoney, Decimal).ToString("#,##0.00")
Ken
--------------------
________________________________________
From: KJ [mailto:kl******@hotmail.com]
Sent: Tuesday, June 22, 2004 4:32 PM
To: microsoft.public.dotnet.languages.vb
Subject: Format function
Hello,
Why does this not work?
txtMoney.Text.Format("#,##0.00")
If I type 100 in txtMoney, it returns #,##0.00
I have never gotten the format function to work in .NET.
--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus ( http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.3.3 - Release Date: 6/18/2004
On 22 Jun 2004 13:32:00 -0700, KJ wrote: Hello,
Why does this not work?
txtMoney.Text.Format("#,##0.00")
If I type 100 in txtMoney, it returns #,##0.00
I have never gotten the format function to work in .NET.
Because the Format function is a member of the String class. txtMoney.Text
is a string and Format is a member of that class.
To use it, you should try:
txtMoney.Text = String.Format("#,##0.00", txtMoney.Text)
--
Chris
dunawayc[AT]sbcglobal_lunchmeat_[DOT]net
To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
* kl******@hotmail.com (KJ) scripsit: Why does this not work?
txtMoney.Text.Format("#,##0.00")
If I type 100 in txtMoney, it returns #,##0.00
Try 'Strings.Format' instead.
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
The formatting constants are different in .NET - although I was under the
impression the classic VB ones worked too.
However, IMO the .NET formatting is better - have a look at ToString() in
the MSDN. The [decimal object].ToString(<format>) is what you're after.
Your code should be along the lines of
CType(txtMoney.Text, Decimal).ToString("C")
I'm sure the resident experts in this group can explain the details of the
formatting functions :D
___________________________________
The Grim Reaper
"KJ" <kl******@hotmail.com> wrote in message
news:d8**************************@posting.google.c om... Hello,
Why does this not work?
txtMoney.Text.Format("#,##0.00")
If I type 100 in txtMoney, it returns #,##0.00
I have never gotten the format function to work in .NET.
KJ,
As the others have suggested. txtMoney.Text.Format is really the shared
function String.Format, VB.NET allows you to called shared members on
instances of objects, as this example demostrates this can cause confused
results. To avoid these confused results I try to avoid calling shared
members on instances of objects (variables, properties, fields, parameters).
For details on using String.Format see: http://msdn.microsoft.com/library/de...formatting.asp http://msdn.microsoft.com/library/de...ormatTopic.asp
As Chris stated, you sample is the same as:
String.Format("#,##0.00")
There are two problems with this.
1. You are not using the value returned from the Format function.
2. You did not specify any placeholders in the format specifier.
Although the second is not important, the first surely is ;-)
Try something like:
Dim amount As Decimal
Dim str As String = String.Format("The total amount is {0:#,##0.00}",
amount)
Hope this helps
Jay
"KJ" <kl******@hotmail.com> wrote in message
news:d8**************************@posting.google.c om... Hello,
Why does this not work?
txtMoney.Text.Format("#,##0.00")
If I type 100 in txtMoney, it returns #,##0.00
I have never gotten the format function to work in .NET.
Hi Ken,
I see this is a dotnet.language.vb MVP contest.
The opinion from a supperdummy, I find yours the nicest.
Cor Dim strMoney As String = "12345.34"
Me.Text = CType(strMoney, Decimal).ToString("#,##0.00")
* "Cor Ligthert" <no**********@planet.nl> scripsit: I see this is a dotnet.language.vb MVP contest.
The opinion from a supperdummy, I find yours the nicest.
I prefer 'CDec' in this situation ;-). Me.Text = CType(strMoney, Decimal).ToString("#,##0.00")
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Hi Herfried, I prefer 'CDec' in this situation ;-).
Me.Text = CType(strMoney, Decimal).ToString("#,##0.00")
Almost the same question was in the adonet newsgroup, this was my answer on
the question.
\\\
Maybe you have seen it already it seems that there was a contest in the
language.vb newsgroup yesterday evening (my time) about this question.
A google link to this one and than
I found the one from Ken the nicest, however a simple answer is that you
have first to convert the string to a decimal before you can use the mask.
///
However I was no compatitor in the contest.
:-)
Cor
Just to let everyone know
THIS WORKED!!!!! :)
Me.Text = CType(strMoney, Decimal).ToString("#,##0.00")
THIS DID NOT WORK!!!! :(
txtMoney.Text = String.Format("#,##0.00", txtMoney.Text)
Thanks for your help!
Ken, THIS DID NOT WORK!!!! :( txtMoney.Text = String.Format("#,##0.00", txtMoney.Text)
Did you read my post, it explains why that one cannot work.
Hope this helps
Jay
"KJ" <kl******@hotmail.com> wrote in message
news:d8**************************@posting.google.c om... Just to let everyone know
THIS WORKED!!!!! :) Me.Text = CType(strMoney, Decimal).ToString("#,##0.00")
THIS DID NOT WORK!!!! :( txtMoney.Text = String.Format("#,##0.00", txtMoney.Text)
Thanks for your help! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Melissa |
last post by:
What specifically causes the Format event of a report's section to fire?
Thanks!
Melissa
|
by: Jean |
last post by:
Hi,
I have a query that contains the following in the WHERE part of the
query:
WHERE....Format(IIf(nz()<>0,,
IIf(nz()<>0,,
IIf(nz()<>0,,
))),"0.0") AS Körperhöhe,....
|
by: Stuart McGraw |
last post by:
I am looking for a VBA "format" or "template" function, that is,
a function that takes a format string and a varying number of
arguments, and substitutes the argument values into the format
string...
|
by: Roy Hills |
last post by:
I've seen two different function prototype formats used for ANSI C,
and I'm unsure as to which is the correct or preferred one.
1st Format (this is what I use)
type function(type, type, type);...
|
by: Matt |
last post by:
I'm trying to write a shared function that will convert all my phone numbers
from format 1234567890 to (123) 456-7890.
Here is my function that I wrote:
Public Shared Function...
| |
by: Ron |
last post by:
Hello,
The following code works in a Form class module but not a
standard module:
Dim d1 As DateTime
Format(d1, "MMMM")
In a standard module I get a squigly line saying that an
argument has...
|
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: sql guy123 |
last post by:
HI,
I'm pretty new to MS SQL,
My problem is setting ....
=Format$(Date(),"mm" & "/1/" & "YYYY")
(Which is from my MS ACCESS database)
|
by: shsandeep |
last post by:
I used the following query to retrieve the date in dd-mon-yyyy format.
db2 => SELECT RTRIM(CHAR(DAY(COVG_TYP_STRT_DT))) || '-' ||
RTRIM(MONTHNAME(COVG_TYP_STRT_DT)) || '-' ||...
|
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...
| |
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: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |