We help IT Professionals succeed at work.

Dim a variable as a unkown type

Gunit2507
Gunit2507 asked
on
Medium Priority
300 Views
Last Modified: 2010-04-23
I have a variable holding a type code that was set earlier

Dim MyType1 As TypeCode = String
Dim MyType2 As TypeCode = Boolean

Then I want to declare a variable using that type code

Dim MyVariable As MyType1 = ""
Dim MyVariable As MyType2 = 1/2/2006



Comment
Watch Question

Commented:

are u mean Declar variable As variable ???

Test Developer/Validator
Commented:
Declarations are static, so you can't do what you want.

But if you declare MyVariable as Object
MyVariable will be able to hold any kind of data ... and you can still use gettype to figure out the real type.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.