Login or Sign Up to become a member!
LessThanDot Sit Logo

LessThanDot

Community Wiki

Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.

LTD Social Sitings

Lessthandot twitter Lessthandot Linkedin Lessthandot friendfeed Lessthandot facebook Lessthandot rss

Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.

Navigation

Google Ads

VB.Net: Create an instance of class from a string using reflection

From Wiki

Jump to: navigation, search

I would not recommend having this in your code. But perhaps sometimes you really need this.

  1. Dim _asm As [Assembly]
  2. _asm = [Assembly].GetAssembly(GetType(System.Windows.Forms.Control))
  3. Dim obj As Control = asm.CreateInstance("System.Windows.Forms." & Me.ComboBox1.Text, True)

The Assembly should be the one containing the class you want to instantiate. The createinstance takes a String being the Fully Qualified Name of the class.

530 Rating: 2.3/5 (3 votes cast)