Noobie表格问题 [英] Noobie Question on Forms

查看:80
本文介绍了Noobie表格问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很抱歉不得不问这个但是......


我有一个表格要求提供SQL连接信息。我想点击保存然后再打开登录表单关闭

表格。


我可以隐藏表单,但它保持表单打开。如果我尝试使用

form.close()然后它结束程序,即使我已经使用newForm.Show()

和newForm.Activate()之前form.Close()。


谢谢您的时间。

Ron。

解决方案
" Capt_Ron" <钙***** @ discussions.microsoft.com> schrieb:

我可以隐藏表单,但它会保持表单打开。如果我尝试使用
form.close()然后它结束程序,即使我在form.Close()之前使用了newForm.Show()
和newForm.Activate()。 / blockquote>


\\\

Public Sub Main()

Dim f As New Form1()

f.Show()

Application.Run()

结束子

///


按钮:


\\\

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/ >


感谢您的回复。


但是,我有点困惑。 />
我在哪里放置Sub Main?在模块中?或者我将该代码添加到Form1的

Sub Main?


Ron。


" Herfried K. Wagner [MVP]"写道:

" Capt_Ron" <钙***** @ discussions.microsoft.com> schrieb:

我可以隐藏表单,但它会保持表单打开。如果我尝试使用
form.close()然后它结束程序,即使我在form.Close()之前使用了newForm.Show()
和newForm.Activate()。 / blockquote>

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

按钮:

\\\
Dim f2作为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/>



Ron


最简单的一个就是在我的主要表单的负载

事件中执行此操作。


在加载事件中,你不做我的事情。显示主体不是

显示。


看到这是伪的

子载荷

dim frm1作为新的SQLForm

如果frm1.showdialog = dialog.ok那么

myconnectionstring = frm1.textbox1.text''虽然这是一个非常好的

不常见的方法

dim frm2作为新的LoginForm

如果frm2.showdialog = dialog.ok那么

user = frm2.textboxuser.text

密码= frm2.textboxpassword.text

检查登录密码

如果密码= false然后

me.close。

结束如果

frm2.dispose

结束如果

frm1.dispose

结束如果


///


再次询问连接这种方式的字符串很少见。


我希望这会有所帮助。


Cor


Sorry to have to ask this but...

I have a form that asks for SQL connection information. I want to close the
form when I click Save and then open the login form.

I can Hide the form but it keeps the form open. If i try and use
form.close() then it ends the program even though I''ve used newForm.Show()
and newForm.Activate() before the form.Close().

Thank you for your time.
Ron.

解决方案

"Capt_Ron" <Ca*****@discussions.microsoft.com> schrieb:

I can Hide the form but it keeps the form open. If i try and use
form.close() then it ends the program even though I''ve used newForm.Show()
and newForm.Activate() before the form.Close().



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

In a button:

\\\
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/>


THank you for your response.

However, I''m a bit confused.
Where do I put the Sub Main? In a module? or do I add that code to Form1''s
Sub Main?

Ron.

"Herfried K. Wagner [MVP]" wrote:

"Capt_Ron" <Ca*****@discussions.microsoft.com> schrieb:

I can Hide the form but it keeps the form open. If i try and use
form.close() then it ends the program even though I''ve used newForm.Show()
and newForm.Activate() before the form.Close().



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

In a button:

\\\
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/>



Ron

The most simple one is in my opinon to do something as this in the load
event of your main form.

In the load event is as long that you don''t do me.show the mainform not
showed.

see this as pseudo
sub load
dim frm1 as new SQLForm
if frm1.showdialog = dialog.ok then
myconnectionstring = frm1.textbox1.text ''Although that this is a very
uncommon method
dim frm2 as new LoginForm
if frm2.showdialog = dialog.ok then
user = frm2.textboxuser.text
password = frm2.textboxpassword.text
check login password
if password = false then
me.close.
end if
frm2.dispose
end if
frm1.dispose
end if

///

Again that asking of the connection string in this way is rare.

I hope this helps something.

Cor


这篇关于Noobie表格问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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