Hi I have a working very small vb.net project however it uses a proprietary com object which is wired in the VB project to handle events from it!
I have changed the name of the com object but syntactical the the following code is correct:
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 the object when the button is clicked and whenever the object gets data it raises an event passing data into either pretransmit or prereceive.
I just cant seem to work out how to do this c#
vb
Private WithEvents PM As comObj.PManager
c#
private comObj.PManager PM;
but what about the WithEvents?
vb
Private Function PreResponse(ByVal s As String) As String Handles PM.PreResponse
Return s
End Function
c#
private string PreResponse(string s)
{
return s;
}
but what about the Handles PM.PreResponse?
vb
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
PM = CreateObject("ObjName.PManager")
End Sub
c#
private void Button1_Click(System.Object sender, System.EventArgs e)
{
PM = Interaction.CreateObject("ObjName.PManager");
}
not sure were i'm going wrong!?
Could I write a vb.net class and use it in c#?