try initializing the pkgCnt to 1 before for each and change to progressCnt = Cint((pkgCnt / pkgTotal) * 100)
Main Topics
Browse All TopicsHere is a snippet of the code I am trying to use:
ProgressBar1.Maximum = 100
ProgressBar1.Minimum = 0
pkgTotal = indexes.Count
Try
If indexes.Count > 0 Then
For Each index In indexes
strBuilder = New System.Text.StringBuilder(
'pass package to buildTree method to create htm page
strBuilder.Append("<div><h
strItem = lbPkgs.Items(index).ToStri
buildTree(strItem, strBuilder)
'End of HTML page
strBuilder.Append("</body>
strBuilder.Append("</html>
oWrite = Create_Text_File(index)
oWrite.Write(strBuilder)
If Not IsNothing(oWrite) Then
oWrite.Close()
End If
strBuilder = Nothing
progressCnt = (pkgCnt / pkgTotal) * 100
ProgressBar1.Value = progressCnt
pkgCnt = pkgCnt + 1
Label1.Text = "# of Files Generated = " & ProgressBar1.Value.ToStrin
Next
ProgressBar1.Value = 0
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
VBRocks...
He should change the "Label1.Text" line to:
Label1.Text = "# of Files Generated = " & pkgCnt
But I stand by my earlier assertion on the progressbar code.
Here is essentially the same piece of code that does in fact make the progressbar go all the way to 100%:
Public Class Form1
Private pkgCnt, pkgTotal, progressCnt As Integer
Private index As Integer
Private indexes As New ArrayList
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For i As Integer = 1 To 300
indexes.Add(i)
Next
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ProgressBar1.Maximum = 100
ProgressBar1.Minimum = 0
pkgTotal = indexes.Count
If indexes.Count > 0 Then
For Each index In indexes
System.Threading.Thread.Sl
progressCnt = (pkgCnt / pkgTotal) * 100
ProgressBar1.Value = progressCnt
pkgCnt = pkgCnt + 1
Label1.Text = "# of Files Generated = " & pkgCnt
Application.DoEvents()
Next
ProgressBar1.Value = 0
End If
End Sub
End Class
Hi Idle_Mind, You know, I believe they both work.
However, as to your "earlier assertion" of: "Add a call to Application.DoEvents() to your loop:" as a
solution? I don't think so. Although it will help the refreshing of the progress bar, it won't stop it's
updating altogether, especially when the last line of code is reached (the progress bar should
be updated to the final value, unless an error occurs and the progress bar update doesn't complete,
which is a possibility.
There may be something else there that we're not seeing.
Business Accounts
Answer for Membership
by: VBRocksPosted on 2007-08-30 at 07:42:10ID: 19800540
One thing I see, set your max like this:
ProgressBar1.Maximum = indexes.Count