Hi Alphonse,
You are getting an object is undefined error because CType does not allow
variables or calculations within the type parameter. The Visual Basic
Language Reference - CType Function documentation shows this:
typename
Any expression that is legal within an As clause in a Dim statement, that
is, the name of any data type, object, structure, class, or interface.
We are not allowed to dim a variable as type System.Type.GetType(...). The
same thing applies to the type parameter of the CType function.
I think you need to use a Select Case statement, as mentioned earlier.
Thank you, Mike
Microsoft, ASP.NET Support Professional
Microsoft highly recommends to all of our customers that they visit the
http://www.microsoft.com/protect site and perform the three straightforward
steps listed to improve your computer’s security.
This posting is provided "AS IS", with no warranties, and confers no rights.
--------------------
> Reply-To: "Alphonse Giambrone" <NOSPAMa->
> From: "Alphonse Giambrone" <NOSPAMa->
> References: <u#>
<>
> Subject: Re: Type Conversion
> Date: Mon, 5 Jan 2004 16:00:14 -0500
> Lines: 72
> X-Priority: 3
> X-MSMail-Priority: Normal
> X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
> Message-ID: <>
> Newsgroups: microsoft.public.dotnet.framework.aspnet
> NNTP-Posting-Host: ool-4352027f.dyn.optonline.net 67.82.2.127
> Path:
cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!cpmsftng xa09.phx.gbl!TK2MSFTNGP08.
phx.gbl!TK2MSFTNGP11.phx.gbl
> Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.framework.aspnet:199830
> X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
>
> Thanks Justin,
>
> That is the type of statement I am looking for, but it does not work.
> Error is, System.Type.GetType is undefined.
>
> --
>
> Alphonse Giambrone
> Email: a-giam at customdatasolutions dot us
>
>
> "S. Justin Gengo" <> wrote in message
> news:...
> > Alphonse,
> >
> > You could do this:
> >
> > Dim i As Integer = CType("1000", System.Type.GetType("System.Int32"))
> >
> > Where:
> > System.Type.GetType([Type Name As String])
> >
> > --
> > Sincerely,
> >
> > S. Justin Gengo, MCP
> > Web Developer / Programmer
> >
> > Free code library at:
> > www.aboutfortunate.com
> >
> > "Out of chaos comes order."
> > Nietzche
> >
> >
> > "Alphonse Giambrone" <NOSPAMa-> wrote in message
> > news:u%...
> > > How can I convert a string to a different type based on another string
> or
> > > other variable?
> > >
> > > For instance, instead of
> > > Dim i as Integer
> > >
> > > i = ctype("1000", Integer)
> > >
> > > I would like to do
> > >
> > > Dim i as Integer
> > >
> > > i = ctype("1000","Integer")
> > >
> > > In other words the type conversion would be done programmatically,
> rather
> > > than specified in the code.
> > >
> > > In old VB the 'types' had values (like Integer =3, Long = 4, etc). Is
> > there
> > > something similar in .NET?
> > >
> > > TIA
> > > --
> > >
> > > Alphonse Giambrone
> > > Email: a-giam at customdatasolutions dot us
> > >
> > >
> > >
> >
> >
>
>
>