将事件用于变暗的变量 [英] Using events for a dimmed variable

查看:114
本文介绍了将事件用于变暗的变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将事件用于不是控件的变暗变量.
这是我变暗的变量:

How can I use the event for a dimmed variable that is NOT a control.
This is my dimmed variable:

Dim engine As New Speech.Recognition.SpeechRecognitionEngine


我要使用事件"engine.SpeechRecognized".


I want to use the event "engine.SpeechRecognized".

推荐答案

使用AddHandler [

请参阅本节的处理事件(动态)"部分文章,了解如何执行此操作:

逐步:在VB.NET中进行事件处理 [^ ]

基本上,它看起来像这样:

Look at the "Handling Events (dynamic)" section of this article to see how to do this:

Step by Step: Event handling in VB.NET[^]

Basically, it would look like this:

AddHandler engine.SpeechRecognized, AddressOf Me.HandleSpeechRecognized



然后,您将需要有一个Sub来处理事件,如下所示:



You would then need to have a Sub to handle the event, like so:

Public Sub HandleSpeechRecognized(ByVal sender As Object, _
           ByVal e As System.EventArgs)
    'Your code here
End Sub


这篇关于将事件用于变暗的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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