This is my 3rd tutorial for the controls in vb.net. The one that i will introduce today is the ProgressBar Control. A ProgressBar indicates the progress of an operation. The ProgressBar control consists of a window that is filled with the system highlight color as an operation progresses.
So, now let's start this tutorial!
1. Let's start with creating a Windows Form Application for this tutorial by following the following steps in Microsoft Visual Studio: Go to File, click New Project, and choose Windows Application.
2. Next, add one ProgressBar named ProgressBar1. Add two labels named lblPercent that will indicate how many percent does the ProgressBar Processed and Label1 which is labeled as "%". Add a button named Button1 so that progressbar will move its process. You must design your layout like this:
3. Now, put this code in Button1_Click. This will create a ProgressBar to move.
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Dim x As Integer = 0
- ProgressBar1.Minimum = 0
- ProgressBar1.Maximum = 100
- For x = 0 To 100
- ProgressBar1.Value = x
- lblPercent.Text = x
- End Sub
We initialized x as an integer variable that we will be using for the For Next Loop.
ProgressBar1.Minimum = 0 - is a syntax used to set the lower value of the ProgressBar to 0. So meaning it will have its value first at 0. And thus, by default it is always set to 0.
ProgressBar1.Maximum = 100 - is a syntax used to set the highest value of the ProgressBar. So meaning it will have its highest value of 100.
For x = 0 To 100 because the ProgressBar will start with 0 and end up at 100.
ProgressBar1.Value = x - this syntax is used to set that the current value of the ProgressBar will be equal to the variable x as it moved.
lblPercent.Text = x means that the label will now have a value regarding the value that holds x variable.
Download the source code below and try it! :)
For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below.
Engr. Lyndon R. Bermoy
IT Instructor/System Developer/Android Developer
STI College - Surigao City
Follow and add me in my Facebook Account: https://www.facebook.com/donzzsky
Visit and like my page on Facebook at: https://www.facebook.com/BermzISware