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
Mike Tomlinson
High School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Top Expert 2009

The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.

Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 1 Answer and 3 Comments.
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>


Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 1 Answer and 3 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004