Dim a variable as a unkown type

Posted on 2006-03-22
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

Question by:Gunit2507
    LVL 6

    Expert Comment


    are u mean Declar variable As variable ???

    LVL 23

    Accepted Solution

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
    Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now