简体   繁体   English

如何调用按钮单击VB6中的事件

[英]How To Call Button Click Event In VB6

I want to call a click in event from a button in VB6, I can't seem to figure it out. 我想通过VB6中的按钮调用事件中的单击,我似乎无法弄明白。 I have tried this code here but it doesn't work. 我在这里试过这个代码,但它不起作用。

Call cmdLoads_Click(Sender, e)

I have also set the sub to public as well, still no luck. 我也将sub设置为public,但仍然没有运气。

The button sub has to have an index: 按钮sub必须有一个索引:

Private Sub cmdLoads_Click(index As Integer)

The name of the command button is cmdLoads, it is really cmdLoads(0). 命令按钮的名称是cmdLoads,它实际上是cmdLoads(0)。 So all I had to do is change the code to this to make it work. 所以我所要做的就是将代码改为此以使其工作。

Call cmdLoads_Click(0)

A command button (or any other object raising events) can have multiple sinks (event subscribers) so calling "xxx_Click" sub will not notify any of the other listeners. 命令按钮(或任何其他引发事件的对象)可以有多个接收器(事件订阅者),因此调用“xxx_Click”sub将不会通知任何其他侦听器。

In short: use cmdLoads(0).Value = True as it's more portable. 简而言之:使用cmdLoads(0).Value = True因为它更便携。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM