To return a boxed object back to a value type you must explicitely unbox the object.
You can unbox using DirectCast() or the CType() function

int myNumber2; 
   if (typeof(Object) Is int)
      Number2 = DirectCast(Object, Integer);

If the Object being boxed is Null or is a reference to an object of a different type an InvalidCastException error occurs.

© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext