将c#转换为vb一个事件,不能直接调用

时间:2015-08-30 11:19:57

标签: c# vb.net

我正在尝试将以下c#代码转换为vb.net,但在vb转换的行中引发了错误:Me.ZBAPI_MEDDOC_CREATE_LINKCompleted

C#:

private void OnZBAPI_MEDDOC_CREATE_LINKOperationCompleted(object arg)
{
    if ((this.ZBAPI_MEDDOC_CREATE_LINKCompleted != null))
    {
        System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
        this.ZBAPI_MEDDOC_CREATE_LINKCompleted(this, new ZBAPI_MEDDOC_CREATE_LINKCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
    }
}

VB:

Private Sub OnZBAPI_MEDDOC_CREATE_LINKOperationCompleted(ByVal arg As Object)
    If (Me.ZBAPI_MEDDOC_CREATE_LINKCompleted IsNot Nothing) Then
        Dim invokeArgs As System.Web.Services.Protocols.InvokeCompletedEventArgs = DirectCast(arg, System.Web.Services.Protocols.InvokeCompletedEventArgs)
        Me.ZBAPI_MEDDOC_CREATE_LINKCompleted(Me, New ZBAPI_MEDDOC_CREATE_LINKCompletedEventArgs(invokeArgs.Results, invokeArgs.[Error], invokeArgs.Cancelled, invokeArgs.UserState))
    End If
End Sub

我应该如何转换c#行this.ZBAPI_MEDDOC_CREATE_LINKCompleted

1 个答案:

答案 0 :(得分:3)

你需要在VB.NET中使用RaiseEvent,如果附加了事件监听器,也不需要Private Sub OnZBAPI_MEDDOC_CREATE_LINKOperationCompleted(ByVal arg As Object) Dim invokeArgs As System.Web.Services.Protocols.InvokeCompletedEventArgs = DirectCast(arg, System.Web.Services.Protocols.InvokeCompletedEventArgs) RaiseEvent ZBAPI_MEDDOC_CREATE_LINKCompleted(Me, New ZBAPI_MEDDOC_CREATE_LINKCompletedEventArgs(invokeArgs.Results, invokeArgs.[Error], invokeArgs.Cancelled, invokeArgs.UserState)) End Sub 检查:

{{1}}