Hi all,

Sorry if this has been asked before, I did a search but couldn't find anything.

I am new to programming and thought I'd start with a GUI menu type thing. One of the options is to tell program's to install one after the other. This works fine but when other people are using it they question how they are supposed know how far it's got.

So I created a form that has the title of what's currently installing, item number e.g 3 of 24 items and a progress bar.
On the actual install form it sets the maximum value of the progress bar based on the number of checkboxes ticked, it then says if checkbox ticked update label on progress form, and then calls a sub which adds one to the current item count (I.e. so it goes 1,2,3,4,5... of x items) and the ProgressBar.Value = to the current item number and tells it to refresh the progress form (progressForm.Refresh - I've tried progressForm.Update as well).

This works fine when there's only a few things to install but when you have a lot of items installing it gets to the 6th or 7th item and then stops updating (labels and progress bar), the program's keep installing fine but just no progress updates.

I've tried on several computers and all have same problem. If I make it so it counts and does a progress bar where the only command between updates is to pause (I think it system.thread.sleep(2000) - I can't remember the exact command but it works) it will then count to anything, the most I got it to do was a 1000 items.

The program's are run with the Shell command and the true variable is used to tell the program to finish before doing the next instruction.

Does anyone know why it does this or if there is a better way? The other progress bars seem to work on the progress of processes rather than counting items.

I'm using vb 2010 by the way.

Thanks in advance

Lee

Edited 4 Years Ago by Killzusall: Spelling

The edit option seems to have disappeared...

Would a background worker on another thread work? and how would I set that up?

Ok sort of done what I wanted to do...

It updates the progress form perfectly
BUT it only works when being debugged by Visual Studio

If I build a release it shows the first update and then shows a white window or, the contents of a window that has loaded behind it, and if I run the debug file through My Computer it does this too, but if I debug it in the IDE it is fine (gets to 79 with no probs - see example).

I have also tried making it so that the progress form has nothing on it no progress bar etc... and that it literally just has a label that doesn't change and all that it has to do is refresh that window and it still blanks/whites out etc.. so i know it's not my progress bar or variables causing problems.

is it because i use the true variable at the end of shell() to make it wait for the prog to finish? I have tried using thread.sleep to give the system a chance to "catch it's breath" before refreshing and it still doesn't work (even tried thred.sleep(10000) - 10 seconds)

Any ideas??

Public Class reburnForm
Private intOkCancel As Integer
Public intCurrent As Integer
Public intCount As Integer
Private intCriticalUpdates As Integer
Private intImportantUpdates As Integer

Private Sub reburnForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
	progressForm.ProgressBar.Value = 0	'When form loads set current progress bar value to 0
	countUpdate()				'This runs a sub that checks how many tick boxes are ticked to give value for intCount (in this case 79)
End Sub

Private Sub installButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles installButton.Click
	progressForm.ProgressBar.Maximum = intCount	'When install button is clicked, set progress bar max. to intCount
	progressForm.ProgressBar.Minimum = 0		'Set progress bar min. to 0
	progressForm.ProgressBar.Step = 1		'Set amount to increase progress bar by everytime as 1
	progressForm.Show()				'Show a windows form that is set to be topmost with progress bar, item# 
	Me.Hide()					'Hide this form so only progress form showing
	If wudCheckBox.Checked Then			'If Windows Updates checked (there are others but removed to keep simple)
		windowsUpdates()			'Run windowsUpdates sub
	End If
	progressForm.ProgressBar.Value = 0		'Now windowsUpdates finished set progress bar value back to 0 (in case of re-runs)
	progressForm.Close()				'Close progress form
	Me.Show()					'Show this form
End Sub

Private Sub windowsUpdates()
	progressForm.progressLabel.Text = "Windows critical updates..."	'Set name on progress form to Windows critical updates
        For Me.intCriticalUpdates = 1 To intCount			'For 1 to intCount (i.e. 79) run
		progressUpdate()					'Run progress update sub
		Shell("WUD" & intCount & ".exe", vbNormalFocus, True)	'Then run wud1.exe, wud2.exe running progress update in between
	Next
End Sub

Private Sub progressUpdate()
	progressForm.ProgressBar.PerformStep()			'Increase progress bar value by step (i.e 1)
	progressForm.ProgressBar.Value = intCurrent		'Use progress bars new value to set intCurrent
	progressForm.currentLabel.Text = intCurrent.ToString	'Set current item label on progress form to intCurrent
	progressForm.Refresh()					'Refresh the progress form to show new info
End Sub

Edited 4 Years Ago by Killzusall: extra info

Fixed it!!!! Swapped Shell() for:

p.StartInfo.FileName =
            p.StartInfo.WorkingDirectory =
            p.StartInfo.Arguments =
            p.Start()
            p.WaitForExit()
This question has already been answered. Start a new discussion instead.