Hello! Does anyone know how to set a progress bar? I am developing an audio and video converter manager. I wanted the progress bar to run 'til the process of the converting of file is finished. The converting time depends on the file size so I can't just set the maximum and minimum counter. Can anyone give me an idea or teach me how to do it? It would be a lot of help on my thesis project. Thanks a lot in advance! ^_^ By the way I am using Visual Studio 2008. :D


try using Threading:

Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports System.Threading

Namespace WFInvoke
	Public Partial Class Form1
		Inherits Form
		Public Sub New()
		End Sub

		<STAThread> _
		Private Shared Sub Main()
			Application.Run(New Form1())
		End Sub

		Private Sub IncrementMe()
			'Instead of this loop use your code for converting
			For i As Integer = 0 To 99
			If InvokeRequired Then
				Invoke(New MethodInvoker(AddressOf Close))
			End If
		End Sub

		Private Sub UpdateProgress()
			If Me.progressBar1.InvokeRequired Then
				Dim updateProgress__1 As MethodInvoker = AddressOf UpdateProgress
			End If
		End Sub

		Private Sub button1_Click(sender As Object, e As EventArgs)
			Dim threadStart As ThreadStart = AddressOf IncrementMe
			threadStart.BeginInvoke(Nothing, Nothing)
		End Sub
	End Class
End Namespace

Thank you Mitja! I'll try to study this one and apply it to my codes. I'll get back to you if this works for my project. God bless! :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.