"Sam" <sa**************@voila.fr> schrieb:
dim SomeVar as Integer
Dim theType As Type = SomeVar.GetType
dim Test as Object
Test = SomeVar
dim myVar = DirectCast(Test, theType) -> compilation error, what is the
work around ?
The second parameter must be known at compile-time. This means that you
cannot pass a 'Type' object to this parameter at runtime. In this
particular case casting would not make sense because you are assigning the
result of the cast to a variable of type 'Object', which is the base class
of all classes.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>