I would like to be able to cast a value dynamically where the type is known only at runtime. Something like this:
myvalue = CType(value, 'String, Integer or Boolean')
The string that contains the type value is passed as an argument and is also read from a database, and the value is stored as string in the database.
Is this possible?
Sure, but
myvaluewill have to be defined as of typeObject, and you don’t necessarily want that. Perhaps this is a case better served by generics.What determines what type will be used?