class from string

  • Thread starter Thread starter kresimir ivkovic
  • Start date Start date
K

kresimir ivkovic

Dear all Guru's

How can I references on class with string ????

Sample like that but ???:

stringRef = "Appl.Main"
Dim someClassX as "Appl.Main"

Thanx for any suggestion

K.I.
 
Dear all Guru's

How can I references on class with string ????

Sample like that but ???:

stringRef = "Appl.Main"
Dim someClassX as "Appl.Main"

You cannot. A type of a variable (or function parameter) in VB is a
compile-time construct. You can create an object of some type which
name is stored in a string at run-time, though:

Dim obj As Object = Activator.CreateInstance(Type.GetType
("Appl.Main"))

However, if you explain why you actually need that sort of thing, it
is very likely that a better design would avoid a need for this kind
of thing.
 
Back
Top