Sunday, May 16, 2010

ProgressBar Visual Basic {VB.net} Detailed Tutorial

Hello and welcome to another tutorial on vb.net. Today in this tutorial i will be teaching u all how to use the progressbar component in visual basic 2005, 2008, 2010.

Requirements:
2 ProgressBar - ProgressBar1, ProgressBar2
1 Label - Label1
4 Buttons (|<<,<<,>>,>>|)

Codes:

Public Class Form1

Dim myprogress As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ProgressBar1.Style = ProgressBarStyle.Marquee
ProgressBar2.Style = ProgressBarStyle.Continuous
ProgressBar2.Step = 1
Timer1.Enabled = True
ProgressBar1.Minimum = 0
ProgressBar1.Maximum = 100
ProgressBar1.Value = 0
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If ProgressBar1.Value <>
ProgressBar1.Value += 5
End If
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If ProgressBar1.Value > 0 Then
ProgressBar1.Value -= 5
End If
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
ProgressBar1.Value = 100
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ProgressBar1.Value = 0
End Sub

Private Sub Form1_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel
If e.Delta > -1 Then
If ProgressBar1.Value <>
ProgressBar1.Value += 5
End If
Else
If ProgressBar1.Value > 0 Then
ProgressBar1.Value -= 5
End If
End If
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
ProgressBar2.Value = myprogress
If myprogress < myprogress =" myprogress">
Label1.Text = "Installing = " & myprogress & "%"
If myprogress = 100 Then
Label1.Text = "Complete"
ProgressBar1.Style = ProgressBarStyle.Continuous
ProgressBar1.Value = 0
Timer1.Enabled = False
End If
End Sub
End Class
_________________________________________________________________________

Here is the video tutorial:




0 comments:

Fish