troubleshooting Question

VB.NET 2005 - Status label not updating with progress bar

Avatar of blitzzy
blitzzy asked on
.NET ProgrammingEditors IDEs
3 Comments1 Solution4302 ViewsLast Modified:
I am writing a program in VB.NET 2005 that contains a StatusStrip, progress bar, and status label. Each time a file is copied, the progress bar increments and the status label should say "Copying fax # xx of xx." The problem is that the progress bar works fine, but the status label is not displayed until the progress bar finishes. When I stepped through the code, I see that the status label is updated correctly; it just isn't displayed until AFTER the progress bar. I would like for the status label to be displayed and updated at the same time that the progress bar is updated. Does this require threading? If so, can someone please show me how (with code) because I have no clue when it comes to threading. Thanks!

[b]Here's my code:[/b]
    Private Sub mnu_ReceiveFaxOn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_ReceiveFaxOn.Click
        If mnu_ReceiveFaxOn.Checked Then
            Exit Sub
            mnu_ReceiveFaxOn.Checked = True
            mnu_ReceiveFaxOff.Checked = False
            sb_Status.Visible = True
            pbar_FaxStatus.Value = 0
            sbl_FaxStatus.Text = ""
        End If
    End Sub

    Private Sub GetNewFaxes()
        Dim ClmFaxes As New DataTable
        Dim BatchNumber As Long
        Dim BatchName As String
        Dim TotalPages As Integer
        Dim SourceFile As String
        Dim DestFile As String
        Dim FaxCounter As Integer
        Dim RecordCount As Integer
        Dim PageCount As Integer

            ClmFaxes = LoadClmFaxes()

            RecordCount = ClmFaxes.Rows.Count

            For FaxCounter = 1 To RecordCount
[b]                sbl_FaxStatus.Text = "Copying fax # " & FaxCounter & " of " & RecordCount[/b]

                BatchNumber = ClmFaxes.Rows(FaxCounter - 1).Item("BaseID")
                BatchName = BatchNumber.ToString("00000000")
                TotalPages = ClmFaxes.Rows(FaxCounter - 1).Item("NumPages")

                For PageCount = 1 To TotalPages
                    SourceFile = My.Settings.ClmFaxFromPath & "\" & BatchName & "." & PageCount.ToString("000")
                    DestFile = My.Settings.ClmFaxTempPath & "\" & BatchName & "." & PageCount.ToString("000")

                    My.Computer.FileSystem.CopyFile(SourceFile, DestFile)

[b]                pbar_FaxStatus.Increment(10)[/b]

            Windows.Forms.Cursor.Current = Cursors.Default
        Catch ex As System.Exception
        End Try
    End Sub
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros