I have an application that I would like to use strings from the textboxes to open forms, by storing the form name in the textbox on open or close.

Dim strName as string
Dim frm as Form
If strName = String.Empty then
strName = frmMain
Else
strName = frmMain.txtFormOpen.txt
frm = strName
End If

but I get an error that a string is not or can not be converted to a form :(

Any help would be greatly appreciated. Thank you in advance

Michael

The application is in VB.NET 2005.

I would like to be able to create code to open the form based on the text in the textbox.

Assign name and open the form with code.

Michael

Ok, thank you, but how do I do that in code please?

The application is in VB.NET 2005.

I would like to be able to create code to open the form based on the text in the textbox.

Assign name and open the form with code.

I have an application that I would like to use strings from the textboxes to open forms, by storing the form name in the textbox on open or close.

Dim strName as string
Dim frm as Form
If strName = String.Empty then
strName = frmMain
Else
strName = frmMain.txtFormOpen.txt
frm = strName
End If

but I get an error that a string is not or can not be converted to a form

Any help would be greatly appreciated. Thank you in advance

Ok, thank you, but how do I do that in code please?

Dim myForm As New Form1
myForm.ShowDialog()

you have confusing program.
iaeDave already answer the question.

Dim myForm As New Form1
myForm.ShowDialog()

that code used to call other form

I think the only way you can do it is via a select case statement and hard code your form names in there, i.e.

Select Case strName
  Case "frm1"
    dim frm as new frm1
  Case "frm1"
    dim frm as new frm2
end select
frm.showdialog()

This is not as restricting as it seems as you will have a finite number of forms at design time, you only need to remember to add them in to the select statement.

This article has been dead for over six months. Start a new discussion instead.