打开另一个表单并在vb.net中关闭 [英] Open Another form and close itself in vb.net

查看:109
本文介绍了打开另一个表单并在vb.net中关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,我首先创建了Login表单。当用户登录时,它打开主要的

表格并关闭登录表单。

For example, I create Login form first. When user login, it open the main
form and close the login form itself.

推荐答案

" Alex" <铝** @ discussions.microsoft.com> schrieb:
"Alex" <Al**@discussions.microsoft.com> schrieb:
例如,我首先创建了Login表单。当用户登录时,它打开主要表单并关闭登录表单。
For example, I create Login form first. When user login, it open the main
form and close the login form itself.




\\\

公共模块计划

Public Sub Main()

Dim f As New Form1()

f.Show()

Application.Run()

End Sub

结束模块

///


在项目属性中,选择Sub Main作为启动对象。将

代码放在按钮'''点击''事件处理程序中:


\\\

Dim f2 As New Form2()

f2.Show()

Me.Close()

///


您可以通过调用''Application.ExitThread''退出应用程序。还可以看看''ApplicationContext''课程。


-

MS Herfried K. Wagner

MVP< URL:http://dotnet.mvps.org/>

VB< URL:http://dotnet.mvps.org/dotnet/faqs/ >



\\\
Public Module Program
Public Sub Main()
Dim f As New Form1()
f.Show()
Application.Run()
End Sub
End Module
///

In the project properties, select ''Sub Main'' as startup object. Place the
code below in a button''s ''Click'' event handler:

\\\
Dim f2 As New Form2()
f2.Show()
Me.Close()
///

You can exit the application by calling ''Application.ExitThread''. Take a
look at the ''ApplicationContext'' class too.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>


为什么下面稍微修改过的代码会导致在Application.Run Line上抛出异常




公共模块计划

Public Sub Main()

Dim f As New Form1()

f.Show()

Application.Run()

End Sub

结束模块


在Form1按钮''点击''事件处理程序:


Dim f2 As New Form2()

f2.ShowDialog()从此对话框返回后注意,抛出异常。

" Herfried K. Wagner [MVP]"写道:
Why does the following slightly modified code cause an exception to be thrown
on the Application.Run Line?

Public Module Program
Public Sub Main()
Dim f As New Form1()
f.Show()
Application.Run()
End Sub
End Module

In Form1 button ''Click'' event handler:

Dim f2 As New Form2()
f2.ShowDialog() Note after return from this Dialog, an exception is thrown.
"Herfried K. Wagner [MVP]" wrote:
" Alex" <铝** @ discussions.microsoft.com> schrieb:
"Alex" <Al**@discussions.microsoft.com> schrieb:
例如,我首先创建了Login表单。当用户登录时,它会打开主要表单并关闭登录表单。
For example, I create Login form first. When user login, it open the main
form and close the login form itself.



\\\
公共模块程序
公开Sub Main()
Dim f As New Form1()
f.Show()
Application.Run()
End Sub
结束模块
/ //

在项目属性中,选择''Sub Main''作为启动对象。将
代码放在按钮'''点击''事件处理程序中:

\\\
Dim f2 As New Form2()
f2.Show()
Me.Close()
///

您可以通过调用''Application.ExitThread''退出应用程序。也可以看看''ApplicationContext''课程。

- MS Herfried K. Wagner
MVP< URL:http:// dotnet .mvps.org />
VB< URL:http://dotnet.mvps.org/dotnet/faqs/>



\\\
Public Module Program
Public Sub Main()
Dim f As New Form1()
f.Show()
Application.Run()
End Sub
End Module
///

In the project properties, select ''Sub Main'' as startup object. Place the
code below in a button''s ''Click'' event handler:

\\\
Dim f2 As New Form2()
f2.Show()
Me.Close()
///

You can exit the application by calling ''Application.ExitThread''. Take a
look at the ''ApplicationContext'' class too.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>



丹尼斯,


" Dennis" <德**** @ discussions.microsoft.com> schrieb:
Dennis,

"Dennis" <De****@discussions.microsoft.com> schrieb:
为什么下面稍微修改过的代码会导致Application.Run线上出现异常


公共模块程序<公共子主体()
Dim f作为新Form1()
f.Show()
Application.Run()
End Sub
结束模块

在Form1按钮''点击''事件处理程序:

Dim f2 As New Form2()
f2.ShowDialog()注意从此对话框返回后,抛出异常。
Why does the following slightly modified code cause an exception to be
thrown
on the Application.Run Line?

Public Module Program
Public Sub Main()
Dim f As New Form1()
f.Show()
Application.Run()
End Sub
End Module

In Form1 button ''Click'' event handler:

Dim f2 As New Form2()
f2.ShowDialog() Note after return from this Dialog, an exception is
thrown.




我无法在我的机器上重现它(.NET 1.1 SP1,Windows XP

专业SP2)。抛出什么异常?你能发布完整的

错误信息吗?


-

MS Herfried K. Wagner

MVP< URL:http://dotnet.mvps.org/>

VB< URL:http://dotnet.mvps.org/dotnet/faqs/>



I am not able to reproduce that on my machine (.NET 1.1 SP1, Windows XP
Professional SP2). What exception is thrown? Can you post the complete
error message?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>


这篇关于打开另一个表单并在vb.net中关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆