调用Sub与假按键 [英] Call Sub vs. fake a key press

查看:70
本文介绍了调用Sub与假按键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,主题可能没有使用正确的术语,但我不确定

在VB中调用它是什么。


我正在写一个媒体播放器应用程序。处理打开文件的子程序

按钮包含一个If语句,用于查看文件是否已经在播放,以及

因此执行一些代码来停止前一个文件从其他

之类的东西中玩。还有一个停止表单上的按钮包含确切的

相同的代码。显然,如果只有一个子程序包含代码,那么将会更容易,并且可以从打开的

例程和停止例程中的If调用该子程序。我的问题是,是否有一种方法可以使程序认为停止。按钮被按下了? I.E.是否有任何

语句我可以将其放入打开文件中的If语句中这将是

" trigger"就像停止一样按钮被按下了?如果是这样的话,

有没有任何警告可以在程序中伪造一个按钮点击而不是

只是将代码放在一个sub中并从两个事件中调用它?


-

谢谢,

Ricky W. Hunt

freendeed

First, the subject probably doesn''t use the correct terms but I''m not sure
what it''s called in VB.

I''m writing a media player app. The subroutine that handles the "open file"
button contains an If statement to see if a file was already playing and if
so executes some code to stop the previous file from playing among other
things. There''s also a "stop" button on the form that contains the exact
same code. Obviously it would be easier if there was just one subroutine
containing the code and that sub would be called from the If in the open
routine and from the stop routine. My question is, is there a way to make
the program think the "Stop" button was pressed? I.E. is there anything
statement I can put in the If statement in the "open file" sub that will
"trigger" just the same as if the "stop" button had been pressed? If so, are
there any caveats to faking a button click from within the program versus
just putting the code in a sub and calling it from both events?

--
Thanks,
Ricky W. Hunt
freendeed

推荐答案

" Ricky W. Hunt" < rh的***** @ hotmail.com>写在

新闻:PINOc.220130
"Ricky W. Hunt" <rh*****@hotmail.com> wrote in
news:PINOc.220130


Oq2.52920@attbi_s52:
Oq2.52920@attbi_s52:
我可以放入If 打开文件中的陈述将触发触发的子就像停止一样按钮被按下了?如果
如此,是否有任何警告可以在
程序中伪造按钮单击,而不是仅将代码放入子程序并从两个
事件中调用它?
I can put in the If statement in the "open file" sub that will
"trigger" just the same as if the "stop" button had been pressed? If
so, are there any caveats to faking a button click from within the
program versus just putting the code in a sub and calling it from both
events?



你可以像以下一样打电话给:

MyButtonPressEvent(我,没什么)


唯一的问题是你的事件arg参数将为空 - 除非当然

你也通过了eventarg。


-

Lucas Tam(RE * *******@rogers.com)

请删除删除来自回复时的电子邮件地址。
http://成员。 ebay.com/aboutme/coolspot18/


" Ricky W. Hunt" < rh的***** @ hotmail.com>写在

news:PINOc.220130
"Ricky W. Hunt" <rh*****@hotmail.com> wrote in
news:PINOc.220130


这篇关于调用Sub与假按键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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