[RESOLVED] Progressbar Totaly lost Help Plz
I never used a progressbar ive tried in old vb6 but never got it, iam loading a text file in a listbox, can some one plz show how it is done heres my code to open and load text in a list box
Many ,Many Thanks
openFileDialog1.Filter = "Text files (*.TXT)|*.TXT"
openFileDialog1.Title = "Select a Cursor File"
If openFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
Dim lines() As String = File.ReadAllLines(openFileDialog1.FileName)
For Each line As String In lines
RepareList.Items.Add(line)
Next
Thank you
Dem
Re: Progressbar Totaly lost Help Plz
The easiest way to do this is to set the MaxValue property to the number of lines (which you can probably get from the lines() array).
Before you start the For Loop, set the Value property to 0 (0%).
Then, increment the Value property with 1 inside the For Loop.
What happens now is that the Value property will be incremented with 1 step, from 0 to 'number of lines'. Because 'number of lines' is also your MaxValue, that will correspond to 100% progress and the progressbar will be 100% filled.
Re: Progressbar Totaly lost Help Plz
Thanks for Replying , can you give me a example, i never had any luck in progressbars
Thank you for Replying
Best, Regards
Dem
Re: Progressbar Totaly lost Help Plz
I told you everything you need to know?
Oh well...
Code:
Dim numberOfLines As Integer = ... 'get number of lines here
ProgressBar1.Value = 0
ProgressBar1.MaxValue = numberOfLines
For Each something something
ProgressBar1.Value += 1
Next
Re: Progressbar Totaly lost Help Plz
Sorry iam losted, i never had any luck in a progressbar i guess vb6 i was lost and in vb2008 i will be too lol
iave tried to incert and change your example but only error
best, regards
Dem
Re: Progressbar Totaly lost Help Plz
It would help if you tell us what errors you are getting, and if you post the new code.
Re: Progressbar Totaly lost Help Plz
openFileDialog1.Filter = "Text files (*.TXT)|*.TXT"
openFileDialog1.Title = "Select a Cursor File"
If openFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
Dim lines() As String = File.ReadAllLines(openFileDialog1.FileName)
Dim lines2 As Integer = RepareList.Text
RepareList.Value = 0
RepareList.MaxValue = lines2
For Each RepareList.Items(lines2)
ProgressBar1.Value += 1
Next
For Each line As String In lines
RepareList.Items.Add(line)
Next
End If
thank you
Re: Progressbar Totaly lost Help Plz
You didn't even do as I did in the example!
What is the purpose of "lines2"?
It's an Integer (number) and you are trying to set a Text (String) property to it.
I told you to set the Value and MaxValue of the ProgressBar, not the RepareList (which I presume is your listbox).
Finally you have added a second For Each loop that loops through an Item, something that does not make sense at all. You want to loop through the lines as usual, and increment the progressbar value inside that loop.
Try adding the following to your first code:
Code:
Dim n As Integer = lines.Count()
Try to work out yourself where this should go, it's not that hard. If you get an error, it is most probably easy enough to understand what you need to change from what it says!
And modify the For Each loop like this:
Code:
ProgressBar1.Value = 0
ProgressBar1.MaxValue = n
For Each line As String In lines
RepareList.Items.Add(line)
ProgressBar1.Value += 1
Next
ProgressBar1.Value = ProgressBar1.MaxValue
Re: Progressbar Totaly lost Help Plz
Thanks you for taking the time and helping
i ll post back on this
Dem
Re: Progressbar Totaly lost Help Plz
Thank You its working and i learned alot :thumb:
:wave:
Best,Regards
Dem