Can you run the same vb.net form more than once?

时间:2015-07-08 15:44:12

标签: vb.net forms

Is it possible to run the same form more than once?

Run form1

Press button1 saves the information of form1 in variables and re-opens form1 for new input.

2 个答案:

答案 0 :(得分:3)

It's probably easier to create a new instance of the form than to try to accurately clear/reset fields and other data.

Forms are just classes. You can create and show as many instances of the from class as you want, just like any other class: 5, 5000, or as many as your computer has the ability to handle.

Of course, you'll still need to write code to save data from the previous instance, and there's a lot left unsaid in the question about how things are laid out right now in terms of where button1 is and what you want to happen in the transition.

答案 1 :(得分:0)

如上所述,表格只是一个类。您可以根据需要创建任意数量的实例。毕竟这是Windows。因此,如果您有一个带有打开表单的按钮的表单,您只需将下面的代码段放在表单点击事件`

Dim frm as theformname    
frm.showdialog`