Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I am returning a string that contains a form name.

 

This form name is the same as a form that needs to be opened.

 

It is possible to hardcode and open the form

 

I want to open the form whose name I will get as string

 

 

like:

Dim frmString as String

Dim objFrm as new frmString

objFrm.Show

 

(I know this is not a solution but wish to do his way...

 

Please please hrlp

  • Administrators
Posted

Create a new project and add a few forms to it. On your startup form add a button and a textbox. Paste the following code into the button click event.

 

Dim f As Form
Dim a As System.Reflection.Assembly
a = System.Reflection.Assembly.GetExecutingAssembly()
f = a.CreateInstance(TextBox1.Text)
f.Show()

 

You will need to type the full classname of the form to display into the textbox.

i.e. WindowsApplication1.Form2

 

 

However is there any reason why you need to do it this way?

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

I tried the code and getting following error

 

user defined type not defined

 

Ok now let me elaborate the necessity.

 

I have generated an application to be used by a company.

 

I have generated a login menu.

 

Based on login id I need to open the the form.

 

Say for example For department A, form Frmgrn need to be opened as start up form

 

as for Department B, the start up form is FrmDO

 

I wil be storing the startup form and Login id's in a table (Access database)

 

Based on login id , I will know the name of 'start up form' for the user and I will open it usinf your script.

 

Thanks in advance please inform em whether I need to incoprorate the something more in 'reference '

 

Thanking you in advance

 

waiting for response

 

Vikas

  • Administrators
Posted

Are all the forms part of the same project (i.e. compiled into the .exe itself)?

If so what is the namespace of the application (Project menu,properties on the right - root namespace)

You need to fully qualify the form name with the correct namespace for this to work.

 

If it doesn't work could you post some code to show where / how it is failing for you.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Guest
This topic is now closed to further replies.
×
×
  • Create New...