From: Tom Shelton on 4 Mar 2010 17:36 On 2010-03-04, Mr. X. <nospam(a)nospam_please.com> wrote: > Thanks. > What is the difference between tryCast and directCast ? > > Thanks :) > > "Herfried K. Wagner [MVP]" <hirf-spam-me-here(a)gmx.at> wrote in message > news:u24#9EnuKHA.5036(a)TK2MSFTNGP02.phx.gbl... >> Am 02.03.2010 23:42, schrieb Mr. X.: >>> If I have the code : sender As System.Object >>> and sender is Button class. >>> How can I refer sender as a button ? >> >> \\\ >> Dim SourceButton As Button = DirectCast(sender, Button) >> ... >> /// >> DirectCast and CType will throw an exception if they can not cast/convert the object to the target type. TryCast will not throw an exception, but return nothing. -- Tom Shelton
From: Armin Zingler on 4 Mar 2010 17:46 Am 04.03.2010 22:51, schrieb Mr. X.: > Thanks. > What is the difference between tryCast and directCast ? Have a look at your keyboard. In the top left, do you see the "Esc" key there? On it's right, there's a key that reads "F1". If you press it, you will get a lot of documentation. This feature is even case sensitive. So, if you press it while the caret is placed on one of these keywords, you will get help about them. ;-) Ok ok, more helpful: (look at the table) http://msdn.microsoft.com/en-us/library/zyy863x8%28VS.80%29.aspx -- Armin
First
|
Prev
|
Pages: 1 2 Prev: Dynamically adding menu items and their OnClick events Next: User Controls Gets bigger |