我习惯用 C# 编程,所以我不知道如何在 VB 中处理委托和传递方法
我得到的错误是:Argument not specified for parameter 'message' of 'Public Sub ReceiveMessage(message As String)'
这是我要传递给的类的构造函数:
Delegate Sub ReceiveDelegate(message As String)
Public ReceiveMethod As ReceiveDelegate
Sub New(ByRef receive As ReceiveDelegate)
ReceiveMethod = receive
End Sub
这是我试图传递给该构造函数的方法:
Public Sub ReceiveMessage(message As String)
MessageBox.Show(message)
End Sub
我这样使用它:
Dim newClass As New Class(ReceiveMessage)
这样做的目的是,一旦该类从网络设备接收到数据,它就可以异步调用 Form 上的相应方法。