Little Help

  • Thread starter Thread starter CJ Taylor
  • Start date Start date
C

CJ Taylor

Hey someone want to help me out with this?

Dim sDType as string
sDType = dReader("sDataType")
retval = ctype(dReader("oParameterValue"),
gettype(System.Type.GetType(sdtype)))



why doesn't this work?

If anyone knows that would be great.



Thanks,

cj
 
CJ Taylor said:
Hey someone want to help me out with this?

Dim sDType as string
sDType = dReader("sDataType")
retval = ctype(dReader("oParameterValue"),
gettype(System.Type.GetType(sdtype)))



why doesn't this work?

- because you use option strict. ;-)
- CType needs a type name, not a type object. GetType returns a type object.

The code wouldn't make sense. How would you declare "retval"? As Object? If
you do, you don't need type casting. If you declare it as a specific type,
you can specify the specific type name as the 2nd argument for CType (or
Directcast). In addition, CType is compiled inline, so the type must be
known at compile time.
 
* "CJ Taylor said:
Hey someone want to help me out with this?

Dim sDType as string
sDType = dReader("sDataType")
retval = ctype(dReader("oParameterValue"),
gettype(System.Type.GetType(sdtype)))

'GetType' is checked at compile time, it cannot be used with an instance
of the 'Type' class. You will have to hardcode the type's name.
 
Yeah.. that was my defense mechanism for... "Damnit... how were yo so stupid
to think that..."


=)
 
CJ Taylor said:
Yeah.. that was my defense mechanism for... "Damnit... how were yo so
stupid to think that..."


yo? me? who? what? where? (don't answer...) ;-)))
 
Back
Top