CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    May 2008
    Posts
    14

    Red face Can anyone change the code from C# to vb.net?

    Can anyone change code from C# to vb.net. The code is as below:

    public void UpdateTextBox(string data)
    {
    if ( txtOutput.InvokeRequired )
    txtOutput.Invoke(new OutputUpdateDelegate(OutputUpdateCallback),
    new object[] { data });
    else
    OutputUpdateCallback(data); //call directly
    }

    private void OutputUpdateCallback(string data)
    {
    txtOutput.Text += data;
    }

    I have tried and that has error on row
    txtOutput.Invoke(new OutputUpdateDelegate(OutputUpdateCallback),

    My code is

    Public Sub UpdateTextBox(ByVal data As String)

    If (TextBox2.InvokeRequired) Then
    TextBox2.Invoke(New OutputUpdateDelegate(OutputUpdateCallback), New Object() {data})
    Else
    OutputUpdateCallback(data) ' //call directly
    End If
    End Sub

    Private Sub OutputUpdateCallback( data As String)

    TextBox2.Text += Data
    End Sub


    thanks in advance

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Can anyone change the code from C# to vb.net?

    Code:
    Dim del As MyDelSub
    Dim del2 As MyDelSub 
    Dim delAll As [Delegate]
    
    del = New MyDelSub(AddressOf WriteToDebug)
    del2 = New MyDelSub(AddressOf WriteToDebug2)
    delAll = MulticastDelegate.Combine(del, del2)
    delAll.DynamicInvoke( Nothing )

    http://www.developerfusion.co.uk/show/5251/2/
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    May 2008
    Posts
    14

    Re: Can anyone change the code from C# to vb.net?

    Quote Originally Posted by dglienna
    Code:
    Dim del As MyDelSub
    Dim del2 As MyDelSub 
    Dim delAll As [Delegate]
    
    del = New MyDelSub(AddressOf WriteToDebug)
    del2 = New MyDelSub(AddressOf WriteToDebug2)
    delAll = MulticastDelegate.Combine(del, del2)
    delAll.DynamicInvoke( Nothing )

    http://www.developerfusion.co.uk/show/5251/2/
    it do not relate to above. Isn't it??

  4. #4
    Join Date
    Aug 2005
    Posts
    198

    Re: Can anyone change the code from C# to vb.net?

    (via Instant VB):

    Public Sub UpdateTextBox(ByVal data As String)
    If txtOutput.InvokeRequired Then
    txtOutput.Invoke(New OutputUpdateDelegate(AddressOf OutputUpdateCallback), New Object() { data })
    Else
    OutputUpdateCallback(data) 'call directly
    End If
    End Sub

    Private Sub OutputUpdateCallback(ByVal data As String)
    txtOutput.Text += data
    End Sub
    David Anton
    Convert between VB, C#, C++, & Java
    www.tangiblesoftwaresolutions.com
    Instant C# - VB to C# Converter
    Instant VB - C# to VB Converter

  5. #5
    Join Date
    May 2008
    Posts
    14

    Re: Can anyone change the code from C# to vb.net?

    ok thanks

  6. #6
    Join Date
    Mar 2007
    Location
    Argentina
    Posts
    579

    Re: Can anyone change the code from C# to vb.net?

    For small pieces of code, here is an online automatic translator.

    http://www.carlosag.net/Tools/CodeTr...r/default.aspx

    Use with care.
    _

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured