Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Casting values at run-time...

Status
Not open for further replies.

aultmike

Programmer
Feb 9, 2009
9
Consider this example:

Dim x As Int32
Dim newValue As String

x = CType(newValue, x.GetType())

I keep getting the design-time error, Type 'x.GetType' is not defined.

Is there a way I can do this? I would like to be able to cast values at run-time depending on the type of values I'm working with.

Thanks!
 
The line
x = CType(newValue, x.GetType())

should be
x = CType(newValue, Int32). Look at the online help for an explanation of CType.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top