Re: Collections

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Ravichandran J.V. (jvravichandran_at_yahoo.com)
Date: 03/24/04


Date: Tue, 23 Mar 2004 23:10:42 -0800

Dim i As Integer
Dim s As String
Dim o As Object

s = "123"
o = s

i = CType(o, Integer) ' succeeds
i = DirectCast(o, Integer) ' fails

There is not so much to be talked abt if you talk of converting an
inbuilt type to another as in your example above. Try casting into a
user-defined class which is modified as MustInherit(if you are VB
oriented) and obtain it through inheritance into another class. Then,
try DiectCast to cast a normal class to that of the MustInherit class
and it will work till the exception is thrown at runtime. Whereas, in
the same scenario, CType will show you an error before compile time. I
am of course talking in terms of VS.Net Ide.

By the way, since you are a MVP-Outlook, I am asking this question. When
I try to switch my identity in Outlook Express 5.0 after having added a
new identity, why does the switch not take place ?

with regards,

J.V.Ravichandran
- http://www.geocities.com/
  jvravichandran
- http://www.411asp.net/func/search?
  qry=Ravichandran+J.V.&cob=aspnetpro
- http://www.southasianoutlook.com
- http://www.MSDNAA.Net
- http://www.csharphelp.com
- http://www.poetry.com/Publications/
  display.asp?ID=P3966388&BN=999&PN=2
- Or, just search on "J.V.Ravichandran"
  at http://www.Google.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Relevant Pages

  • Re: Catastrophic Failure
    ... switch and made a fresh db with all the objects imported. ... Dim cnn As ADODB.Connection ... Dim prm As ADODB.Parameter ...
    (microsoft.public.access.forms)
  • FYI: IIf() oder Switch()?
    ... Dim res As Double ... x = Timer() ... IIf(): 6,714844 ... Switch(): 11,62109 ...
    (microsoft.public.de.access)
  • Re: Printing Several Documents folder without opening separately
    ... change the switch in the line ... Dim strFileName As String ... Dim fDialog As FileDialog ... Set oDoc = Documents.Open ...
    (microsoft.public.word.docmanagement)
  • Re: Copy Multiple Tables to Clipboard
    ... Dim oDocInsert As Document ... Dim lTbl As Long ... Dim oRngInsert As Range ... when I try to switch back to the first (using ...
    (microsoft.public.word.vba.general)
  • RE: datagridview Combobox editing
    ... If (TypeOf e.Control Is DataGridViewComboBoxEditingControl) Then ... Dim cmb As DataGridViewComboBoxEditingControl = CType(e.Control, ... To switch on the auto complete set the deault property of th combobox cell ... If keyData = Keys.Return Then ...
    (microsoft.public.vsnet.general)