Note that there are some explanatory texts on larger screens.

plurals
  1. POvb.net to c# help
    primarykey
    data
    text
    <p>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!</p> <p>I have changed the name of the com object but syntactical the the following code is correct:</p> <pre><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 </code></pre> <p>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.</p> <p>I just cant seem to work out how to do this c#</p> <p>vb</p> <pre><code>Private WithEvents PM As comObj.PManager </code></pre> <p>c#</p> <pre><code>private comObj.PManager PM; </code></pre> <p>but what about the WithEvents?</p> <p>vb</p> <pre><code>Private Function PreResponse(ByVal s As String) As String Handles PM.PreResponse Return s End Function </code></pre> <p>c#</p> <pre><code>private string PreResponse(string s) { return s; } </code></pre> <p>but what about the Handles PM.PreResponse?</p> <p>vb</p> <pre><code>Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click PM = CreateObject("ObjName.PManager") End Sub </code></pre> <p>c#</p> <pre><code>private void Button1_Click(System.Object sender, System.EventArgs e) { PM = Interaction.CreateObject("ObjName.PManager"); } </code></pre> <p>not sure were i'm going wrong!?</p> <p>Could I write a vb.net class and use it in c#?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload