| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 721 人关注过本帖
标题:C# 转为 VB.net
只看楼主 加入收藏
aqhwj
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2011-4-11
收藏
 问题点数:0 回复次数:0 
C# 转为 VB.net
小弟在将C#转为VB时,遇见如下问题,请各位路过时,指教一二,谢谢!

将C#转为VB时,这段代码总是编译不成功
Public Custom Event SolicitationEvent As EventHandler
        AddHandler(ByVal value As EventHandler)
            _solicitationEvent += value
        End AddHandler

        RemoveHandler(ByVal value As EventHandler)
            _solicitationEvent -= value
        End RemoveHandler
    End Event
错误信息:
缺少事件“SolicitationEvent”的“RaiseEvent”定义。
“Private Event _solicitationEvent(sender As Object, e As System.EventArgs)”是事件,不能直接调用。请使用“RaiseEvent”语句引发事件。
“Private Event _solicitationEvent(sender As Object, e As System.EventArgs)”是事件,不能直接调用。请使用“RaiseEvent”语句引发事件。

下面是源码
C#:
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;

namespace LTP.DBUtility
{
    public enum EffentNextType
    {
        /// <summary>
        /// 对其他语句无任何影响
        /// </summary>
        None,
        /// <summary>
        /// 当前语句必须为"select count(1) from .."格式,如果存在则继续执行,不存在回滚事务
        /// </summary>
        WhenHaveContine,
        /// <summary>
        /// 当前语句必须为"select count(1) from .."格式,如果不存在则继续执行,存在回滚事务
        /// </summary>
        WhenNoHaveContine,
        /// <summary>
        /// 当前语句影响到的行数必须大于0,否则回滚事务
        /// </summary>
        ExcuteEffectRows,
        /// <summary>
        /// 引发事件-当前语句必须为"select count(1) from .."格式,如果不存在则继续执行,存在回滚事务
        /// </summary>
        SolicitationEvent
    }   
    public class CommandInfo
    {
        public object ShareObject = null;
        public object OriginalData = null;
        event EventHandler _solicitationEvent;
        public event EventHandler SolicitationEvent
        {
            add
            {
                _solicitationEvent += value;
            }
            remove
            {
                _solicitationEvent -= value;
            }
        }
        public void OnSolicitationEvent()
        {
            if (_solicitationEvent != null)
            {
                _solicitationEvent(this,new EventArgs());
            }
        }
        public string CommandText;
        public System.[] Parameters;
        public EffentNextType EffentNextType = EffentNextType.None;
        public CommandInfo()
        {

        }
        public CommandInfo(string sqlText, SqlParameter[] para)
        {
             = sqlText;
            this.Parameters = para;
        }
        public CommandInfo(string sqlText, SqlParameter[] para, EffentNextType type)
        {
             = sqlText;
            this.Parameters = para;
            this.EffentNextType = type;
        }
    }
}


Imports System.Collections.Generic
Imports System.Text
Imports System.Data.SqlClient

Public Class CommandInfo
    Public ShareObject As Object = Nothing
    Public OriginalData As Object = Nothing
    Private Event _solicitationEvent As EventHandler

    Public Custom Event SolicitationEvent As EventHandler
        AddHandler(ByVal value As EventHandler)
            _solicitationEvent += value
        End AddHandler

        RemoveHandler(ByVal value As EventHandler)
            _solicitationEvent -= value
        End RemoveHandler
    End Event

    Public Sub OnSolicitationEvent()
        RaiseEvent _solicitationEvent(Me, New EventArgs())
    End Sub


    Public CommandText As String
    Public Parameters As System.()
    Public EffentNextType As EffentNextType = EffentNextType.None

    Public Sub New()
    End Sub
    Public Sub New(ByVal sqlText As String, ByVal para As SqlParameter())
         = sqlText
        Me.Parameters = para
    End Sub
    Public Sub New(ByVal sqlText As String, ByVal para As SqlParameter(), ByVal type As EffentNextType)
         = sqlText
        Me.Parameters = para
        Me.EffentNextType = type
    End Sub
End Class
搜索更多相关主题的帖子: 成功 
2011-04-11 11:25
快速回复:C# 转为 VB.net
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018177 second(s), 9 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved