CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2008

    Help: what's wrong with this code snippet?

    public notinheritable class myClass
    Private txt As String = ""
    Public Delegate Sub SetInfoPercentageDelegate(ByVal Percentage As Integer)
    Public Sub SetInfo(ByVal Text As String)
    txt = Text
    If Me.InvokeRequired Then
    Dim SI As New SetInfoTextDelegate(AddressOf SetInfo)
    Me.Invoke(SI, New Object() {Text})
    tbStatus.Text = Text
    End If
    End Sub
    End class
    My problem: According to my reasoning, when an invoke is required, the if condition is satisfied and the program should execute the IF part. And since in the IF part, the Setinfo method is invoked, the program should run through the Else part on the next step. But it doesn't do so... Can anybody help me with this? Thanks.
    Last edited by HanneSThEGreaT; February 14th, 2009 at 03:32 AM. Reason: Added Code Tags!

  2. #2
    Join Date
    Jan 2006
    Fox Lake, IL

    Re: Help: what's wrong with this code snippet?

    Use CODE TAGS, please.

    I think it's your definition. You need to assign something to i.
      Dim SI As New SetInfoTextDelegate(AddressOf SetInfo)
    Try something like this:

      Dim SI As SetInfoTextDelegate= New SetInfoTextDelegate(AddressOf SetInfo)

    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!

Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.