Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Label will not update with new text

Status
Not open for further replies.

Sorwen

Technical User
Nov 30, 2002
1,641
US
So I have a label on a form that is supposed to receive text and add it to the label so you can see the progress. (some of code is like this just to test)
Code:
Public Class info
    Public Result As String = ""
    Private LastText As String = ""

    Public Sub sMessage(ByVal value As String)
        If Me.InvokeRequired Then
            Me.BeginInvoke(New delSendText(AddressOf SendText), value)
        Else
            SendText(value)
        End If
    End Sub

    Private Delegate Sub delSendText(ByVal value As String)
    Private Sub SendText(ByVal value As String)
        Application.DoEvents()
        MsgBox(value)
        update_lbl.Text = value
        update_lbl.Refresh()
        LastText = value
    End Sub

    Private Sub info_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Result = ""
        Application.DoEvents()
    End Sub

    Private Sub update_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles update_btn.Click
        Result = "update"
    End Sub

    Private Sub cancel_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cancel_btn.Click
        Result = "cancel"
    End Sub

    Private Sub update_lbl_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles update_lbl.Click
        update_lbl.Text = LastText
        Application.DoEvents()
        MsgBox(LastText)
    End Sub
End Class
As you can see I've tried several things and no matter what the labels text will not update. The first message box pops up with the correct text so it is getting passed, but the label and LastText are not updated (the second message box is always empty). Any ideas?

-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!
 
oops. nm I found the problem.

-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top