简单问题....再次......同样...... [英] Simple Problem....again...same...

查看:46
本文介绍了简单问题....再次......同样......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

昨天这个查询有一个很长的线程。 (您可以通过发件人''发件人''搜索

这个主题''简单问题''发布日期10月7日时间

1:43p)


最后,下面的代码决定打开一个新表格:


---按钮点击事件中的代码:button1

如果frm什么都没有那么

frm = new form2()

frm.show

endif


---任何程序以外的代码

dim frm as form2


现在我们第一次点击这个按钮(button1) )它显示form2。现在我们

关闭这个表格2。现在当我们再次点击button1 ........没什么

HAPPENS .........它再也没有打开form2 ......... .........为什么?

解决方案

Hi Sender,


你宣布frm在任何程序之外。你是否以任何其他方式使用这个变量?或者只是从button1_click中创建并显示一个form2?


如果你不使用它点击其他任何东西:

子点击

Dim frm As New Form2

frm.Show


如果你将它用于其他目的,它会更棘手。告诉我哪个。


问候,

Fergus


ps。在另一个查询中还有另一个回复。(上下文菜单& left

mouse)。


" Sender" <我们** @ domain.com> schrieb

昨天这个查询有一个很长的线程。 (你可以通过帖子''发送者''搜索
主题''简单问题''发布日期
10月7日时间1:43p)

结束以下代码决定打开一个新表单:

---单击按钮事件中的代码:button1
如果frm什么都不是那么
frm = new form2 ()
frm.show
endif

---代码以外的任何程序
dim frm as form2

现在第一次我们单击此按钮(button1),它显示form2。
现在我们关闭此form2。现在,当我们再次点击button1
........什么都没发生.........它再也没有打开form
......... .........为什么?




因为当关闭form2时你没有将frm设置为Nothing。处理关闭的

事件的frm,设置frm = Nothing。当然,frm不能在当地宣布



-

Armin


Hi Sender,对象被释放,但它没有被解除引用,所以没有什么

将总是评估为False。


要再次使用它,你必须重新复制...尝试以下


''///将此代码放入按钮单击


''这会创建一个表单实例,如果不存在则

如果frm是Nothing那么

frm = New Form2()

结束如果


''这将显示表格,如果它是不可见的。

如果不是frm.Visible那么

frm.Show()

结束如果


-

HTH,

- Tom Spink,überGeek


请回复新闻组,

所以所有人都可以受益


" ; System.Reflection Master"


====转换为2002 ====

删除内联声明

"发送者QUOT; <我们** @ domain.com>在留言中写道

新闻:eK ************** @ tk2msftngp13.phx.gbl ...

昨天有一个非常这个查询的长线程。 (你可以通过帖子''发送者''搜索主题''简单问题''发布日期10月7日
时间1:43p)

结束以下代码决定打开一个新表单:

---单击按钮事件中的代码:button1
如果frm什么都不是那么
frm = new form2 ()
frm.show
endif

---代码以外的任何程序
dim frm as form2

现在第一次我们单击此按钮(button1),它显示form2。现在
我们关闭这个表格2。现在当我们再次点击button1 ........没有
HAPPENS .........它再也没有打开form2 ............. .....为什么?



Yesterday there was a very long thread on this query. (You can search on
this by post by ''sender'' with subject ''Simple Problem'' post date Oct 7 time
1:43p)

And in the end the following code was decided to open a new form:

---Code in the click event of a button: button1
if frm is nothing then
frm = new form2()
frm.show
endif

---Code outside any procedure
dim frm as form2

Now when first time we click on this button (button1) it shows form2. Now we
close this form2. Now when we again click button1 ........NOTHING
HAPPENS.........it doesn''t open form2 again..................WHY ?

解决方案

Hi Sender,

You declare frm outside any procedures. Do you use this variable in any
other way or is it just to create and show a form2 from within button1_click ?

If you don''t use it for anything else put it in click:
sub click
Dim frm As New Form2
frm.Show

If you use it for other purposes it''s more tricky. Tell me which.

Regards,
Fergus

ps. There''s another reply to you in the other query.(context menu & left
mouse).


"Sender" <us**@domain.com> schrieb

Yesterday there was a very long thread on this query. (You can search
on this by post by ''sender'' with subject ''Simple Problem'' post date
Oct 7 time 1:43p)

And in the end the following code was decided to open a new form:

---Code in the click event of a button: button1
if frm is nothing then
frm = new form2()
frm.show
endif

---Code outside any procedure
dim frm as form2

Now when first time we click on this button (button1) it shows form2.
Now we close this form2. Now when we again click button1
........NOTHING HAPPENS.........it doesn''t open form2
again..................WHY ?



Because you don''t set frm to Nothing when form2 is closed. Handle the closed
event of frm, there set frm = Nothing. Of course, frm mustn''t be declared
locally.
--
Armin


Hi Sender, the object is disposed, but it''s not dereferenced, so Is Nothing
will always evaluate to False.

To use it again, you''ll have to reinstantiate... Try the following

'' /// Put this code in your button click

'' This creates an instance of the form, if none exists
If frm Is Nothing Then
frm = New Form2()
End If

'' This will show the form if it is invisible.
If Not frm.Visible Then
frm.Show()
End If

--
HTH,
-- Tom Spink, über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations
"Sender" <us**@domain.com> wrote in message
news:eK**************@tk2msftngp13.phx.gbl...

Yesterday there was a very long thread on this query. (You can search on
this by post by ''sender'' with subject ''Simple Problem'' post date Oct 7 time 1:43p)

And in the end the following code was decided to open a new form:

---Code in the click event of a button: button1
if frm is nothing then
frm = new form2()
frm.show
endif

---Code outside any procedure
dim frm as form2

Now when first time we click on this button (button1) it shows form2. Now we close this form2. Now when we again click button1 ........NOTHING
HAPPENS.........it doesn''t open form2 again..................WHY ?



这篇关于简单问题....再次......同样......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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