I want to load a form dynamically by reading Form Name from a text file using vb.net. In visual basic 6 code works fine but when i use the same code in vb.net it gives the error.
The code below works perfect in visual basic 6:
Dim form_name As String
dim search_name() as string
form_name = search_name(0)
Dim obj As Form
Set obj = Forms.Add(form_ name)
obj.Show
Basically it reads the name of the form from a text file and store it in form_name variable, then it add that form in the form collection using forms.add(form_ name) and load that form succesfully.
but when i do that same code in vb.net, it gives the following error in the line:
1)obj=forms.add (form_name)
(error: Name 'Forms' is not declared).
I try these things also,but it does not solve my problem.
2)obj = System.Windows. Forms.Add(form_ name)
(error: 'Add' is not a member of 'Forms')
3)Dim obj As Form = DirectCast(form _name, Form)
obj.Show()
(error: Specified cast is not valid)
can anybody explain me how to achieve this in vb.net 2003?However i get the form name from a text file and based on that name i load that existing form. for ex: i have added a form named "Main Menu". Now i want to read data from a text file and when form name matches it load "Main Menu" form. How can i do this:
Regards:
Danish Majid
The code below works perfect in visual basic 6:
Dim form_name As String
dim search_name() as string
form_name = search_name(0)
Dim obj As Form
Set obj = Forms.Add(form_ name)
obj.Show
Basically it reads the name of the form from a text file and store it in form_name variable, then it add that form in the form collection using forms.add(form_ name) and load that form succesfully.
but when i do that same code in vb.net, it gives the following error in the line:
1)obj=forms.add (form_name)
(error: Name 'Forms' is not declared).
I try these things also,but it does not solve my problem.
2)obj = System.Windows. Forms.Add(form_ name)
(error: 'Add' is not a member of 'Forms')
3)Dim obj As Form = DirectCast(form _name, Form)
obj.Show()
(error: Specified cast is not valid)
can anybody explain me how to achieve this in vb.net 2003?However i get the form name from a text file and based on that name i load that existing form. for ex: i have added a form named "Main Menu". Now i want to read data from a text file and when form name matches it load "Main Menu" form. How can i do this:
Regards:
Danish Majid
Comment