Hi I have a very small vb.net project, but it uses its own com-object, which is connected to the VB project to process events from it!
I changed the name of the COM object, but the syntax is correct code:
Public Class Form1
Private WithEvents PM As comObj.PManager
Delegate Sub SetTextCallback([text] As String)
Private Function PreTransmit(ByVal s As String) As String Handles PM.PreTransmit
Me.SetText(s)
Return s
End Function
Private Function PreResponse(ByVal s As String) As String Handles PM.PreResponse
Return s
End Function
Private Sub SetText(ByVal [text] As String)
If Me.textBox1.InvokeRequired Then
Dim d As New SetTextCallback(AddressOf SetText)
Me.Invoke(d, New Object() {[text]})
Else
Me.textBox1.Text = [text]
End If
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
PM = CreateObject("ObjName.PManager")
End Sub
End Class
The above code creates an object when the button is clicked, and whenever the object receives data, it passes the event transmission data to preransmit or prereceive.
I just can't figure out how to do this C #
Vb
Private WithEvents PM As comObj.PManager
WITH#
private comObj.PManager PM;
but what about WithEvents?
Vb
Private Function PreResponse(ByVal s As String) As String Handles PM.PreResponse
Return s
End Function
WITH#
private string PreResponse(string s)
{
return s;
}
but what about PM.PreResponse processings?
Vb
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
PM = CreateObject("ObjName.PManager")
End Sub
WITH#
private void Button1_Click(System.Object sender, System.EventArgs e)
{
PM = Interaction.CreateObject("ObjName.PManager");
}
Not sure if I'm wrong !?
Can I write a vb.net class and use it in C #?