🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.csharpbuilder.language.csharp
Article #404

Re: FormatText

#404
From: Jeff
Date: Tue, 20 Sep 2005 11:51
42 lines
2324 bytes
David:

If I want to display the exception in a message box, don' t I trap it 
like this?

try {
   decimal aValue = Decimal.Parse(TextBox3.Text);
   TextBox3.Text = System.String.Format("{0:C2}", aValue);
}
  catch (FormatException e) {
  MessageBox.Show("Error: "+e, "Error Formatting Total",
				 System.Windows.Forms.MessageBoxButtons.OK, MessageBoxIcon.Asterisk);

}

I get the following error:

[C# Error] FrmPOS.cs(597): A local variable named 'e' cannot be declared 
in this scope because it would give a different meaning to 'e', which is 
already used in a 'parent or current' scope to denote something else

TIA

David Clegg wrote:
> Jeff wrote:
> 
> 
>>aValue = TextBox3.Text;
>>TextBox3.Text = System.String.Format("{0:C2}", aValue);
> 
> 
> You need to convert TextBox3.Text to a decimal first. Try the following
> :-
> 
> try {
>   decimal aValue = Decimal.Parse(TextBox3.Text);
>   TextBox3.Text = System.String.Format("{0:C2}", aValue);
> }
> catch (FormatException) {
>   //Do something with FormatException
> }
> 
Technical Details
Message-ID: <432ff77c$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!newsfeed.icl.net!newsfeed.fjserv.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.inode.at!reader.uucp.at!newsfeed.uucp.at!news.uucp.at!newsgroups.borland.com!not-for-mail
References: <432f6234$1@newsgroups.borland.com> <xn0e7gxqh1rc847009@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 1efe35,95e04c7c9049104a
X-Google-Attributes: gid1efe35,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Tue, 20 Sep 2005 06:51:48 -0500
From: Jeff <jbarr62307@worldnet.att.net>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.csharpbuilder.language.csharp
Subject: Re: FormatText
References: <432f6234$1@newsgroups.borland.com> <xn0e7gxqh1rc847009@newsgroups.borland.com>
In-Reply-To: <xn0e7gxqh1rc847009@newsgroups.borland.com>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 208.242.241.231
Message-ID: <432ff77c$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1127217020 208.242.241.231 (20 Sep 2005 04:50:20 -0700)
Lines: 42
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!newsfeed.icl.net!newsfeed.fjserv.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.inode.at!reader.uucp.at!newsfeed.uucp.at!news.uucp.at!newsgroups.borland.com!not-for-mail