Dim frm As Form

  • Thread starter Thread starter Dib
  • Start date Start date
D

Dib

Hi,

How can I call a form at run-time based on the value from a table.


Dim frm as Form
Dim sForm as String


sForm = rs.Fields(1).Value

frm.Name=sForm

frm.Show()

This is what I am doing. Is this wrong?

What is the correct syntex.

Thanks
Dib
 
Dib said:
How can I call a form at run-time based on the value from a table.

\\\
Dim frm As Form = _
DirectCast( _
Activator.CreateInstance( _
Type.GetType("MyApplication.SampleForm") _
), _
Form _
)
frm.Show()
///
 
Thanks for your reply. This is too much for me!

I set the code like this
Dim frm As Form = DirectCast(Activator.CreateInstance(Type.GetType(sForm)),
Form)

and I got an error Value cannot be Null



What did I do wrong?



Thanks

Dib
 
Got it to work, thanks
Dib

Herfried K. Wagner said:
\\\
Dim frm As Form = _
DirectCast( _
Activator.CreateInstance( _
Type.GetType("MyApplication.SampleForm") _
), _
Form _
)
frm.Show()
///
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top