我在 VBA 有一堂课:
Option Explicit
Private mo As omMsg.Message
Private Sub Class_Initialize()
Set mo = New omMsg.Message
End Sub
Private Sub mo_OnMessageSend(ByVal status As omMsg.ProcessStatus, ByVal msg As String)
ProcessComMessage status, msg
End Sub
mo_OnMessageSend 没有被调用。
C#类如下:
namespace omMsg
{
public interface IMessage
{
void sendMessage(Message.ProcessStatus status, string msg);
event Message.MessageHandler OnMessageSend;
}
[ClassInterface(ClassInterfaceType.None)]
public class Message : IMessage
{
public enum ProcessStatus { Retrieving, Generating, Error, Complete }
public delegate void MessageHandler(ProcessStatus status, string msg);
public event MessageHandler OnMessageSend;
public void sendMessage(ProcessStatus status, string msg)
{
if (OnMessageSend != null)
OnMessageSend(status, msg);
}
}
}
请帮忙。我做对了吗?
谢谢。