转换事件从C#VB.Net ......怎么样? [英] Convert event from C# to VB.Net...how to?

查看:105
本文介绍了转换事件从C#VB.Net ......怎么样?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要转换一个C#code到VB.NET,但我有一些问题....你能帮助我吗?

I have to convert an C# code to VB.NET, but I've some problem....can you help me?

这是C#源:

public static event ValueEnterEventHandler CallEvent;

public static void DispatchCompanyCall(string moduleName)
{
     if (IsReady && CallEvent != null)
           CallEvent(null, new ValueEnterEventArgs(moduleName, false));
}

我已经tryed这样的:

I have tryed this:

Public Shared Event CallEvent As ValueEnterEventHandler

Public Shared Sub DispatchCompanyCall(moduleName As String)
    If IsReady AndAlso CallEvent IsNot Nothing Then
        CallEvent(Nothing, New ValueEnterEventArgs(moduleName, False))
    End If
End Sub

但我有此错误信息:CallEvent是一个事件,不能直接调用,使用RaiseEvent语句引发一个事件

but I've this error message: CallEvent is an event and cannot called directly, use RaiseEvent statement to raise an event

我应该怎么写?你能帮助我吗?谢谢你。

What should I write? Can you help me? Thanks.

推荐答案

使用VB.Net没有必要检查 / 事件没有什么键,就可以直接通过的RaiseEvent 关键字只是提出来

With VB.Net there is no need to check events for null / Nothing and you can just raise them directly via the RaiseEvent keyword

Public Shared Sub DispatchCompanyCall(moduleName As String)
    If IsReady Then
        RaiseEvent CallEvent(Nothing, New ValueEnterEventArgs(moduleName, False))
    End If
End Sub

这篇关于转换事件从C#VB.Net ......怎么样?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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