How to use VB6.0's Event.

Creat a new class named Class1, it's codes like this:

Public Event MyEvent()

Public Sub RaiseTheEvent()
    'some other codes here
    RaiseEvent MyEvent
   
End Sub

Create a new form, draw a command on it named Command1, double the command to open the code.

It codes like this:

Option Explicit

Private WithEvents Myclass As class1


Private Sub Command1_Click()
    Set Myclass = New class1
    Call Myclass.RaiseTheEvent 'In this sub event is raised.

End Sub

Private Sub Myclass_MyEvent()'this is the sub to dill with the event.
    MsgBox "class1's event occured."
End Sub

Start the application and Click the button will raise the event.

没有更多推荐了,返回首页

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试

关闭