🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: FormatText

#405
From: David Clegg
Date: Tue, 20 Sep 2005 20:27
49 lines
2629 bytes
Jeff wrote:

> [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

Thats because there is a System.EventArgs parameter called 'e' passed
into the event handler. Simply give the variable in the exception
handler a different name


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

}

Also, the code above will use the .ToString() method of the
FormatException class which, IIRC, will also include a full stack
trace. If you only want to see the actual error message, use
exception.Message.

And in case you weren't aware, exceptions may also be wrappers for
other exceptions (especially if an exception has been handled and
rethrown as a different type). So in some circumstances it may be
desirable to navigate down the Exception.InnerException chain to get
the full exception details.

HTH.

-- 
Cheers,
David Clegg
dclegg@gmail.com

Vote 1 http://cc.borland.com/codecentral/ccweb.exe/listing?id=21489 :-)
Now supports Google Groups searching with Dyna-extend(tm) technology!

QualityCentral. The best way to bug Borland about bugs.
http://qc.borland.com

"Marge, your paintings look like the things they look like." - Homer
Simpson.
Technical Details
Message-ID: <xn0e7i3ymkm89001@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <432f6234$1@newsgroups.borland.com> <xn0e7gxqh1rc847009@newsgroups.borland.com> <432ff77c$1@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
From: "David Clegg" <dclegg@gmail.com>
Subject: Re: FormatText
Newsgroups: borland.public.csharpbuilder.language.csharp
References: <432f6234$1@newsgroups.borland.com> <xn0e7gxqh1rc847009@newsgroups.borland.com> <432ff77c$1@newsgroups.borland.com>
Organization: eBet Limited
User-Agent: XanaNews/1.17.6.2
X-Face: d0!4zUWIBj<CO5m0`=Vu"m.2)(~|1-4:I]5n5<OE<hv+kK)Z:n<h&MnW9t_{}>cw&gbV#f>mHS4h1mcw[cz:R#J,T;)w/($:2Vl5CQnFP(c\wmN0rSvn25.kmVpCmqb]gj7l9ZP+O4+a+P~L#]4s""Tx^zQ/N"#'/?lV?SHpdR\5(iNj.,I_YMfF=/_3.JWAs3
Message-ID: <xn0e7i3ymkm89001@newsgroups.borland.com>
X-Ref: newsgroups.borland.com ~XNS:00000D9C
NNTP-Posting-Host: 210.55.248.220
Date: 20 Sep 2005 13:27:00 -0700
X-Trace: newsgroups.borland.com 1127248020 210.55.248.220 (20 Sep 2005 13:27:00 -0700)
Lines: 49
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail