Sabtu, 06 Juni 2015

Proggress Bar Visual Basic 2010









Coding:


Public Class Form1
    Inherits Form
    Friend WithEvents Bar As System.Windows.Forms.ProgressBar
    Friend WithEvents lblProgress As System.Windows.Forms.Label
    ' (Designer code omitted.)
    Property Value() As Integer
        Get
            Return Bar.Value
        End Get
        Set(ByVal Value As Integer)
            Bar.Value = Value
            UpdateLabel()
        End Set
    End Property
    Property Maximum() As Integer
        Get
            Return Bar.Maximum
        End Get
        Set(ByVal Value As Integer)
            Bar.Maximum = Value
        End Set
    End Property
    Property [Step]() As Integer
        Get
            Return Bar.Step
        End Get
        Set(ByVal Value As Integer)
            Bar.Step = Value
        End Set
    End Property
    Public Sub PerformStep()
        Bar.PerformStep()
        UpdateLabel()
    End Sub
    Private Sub UpdateLabel()
        lblProgress.Text = ((Bar.Value * 100) \ Bar.Maximum).ToString()
        lblProgress.Text &= "% Done"
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Timer1.Start()
        Timer1.Enabled = False
        ProgressBar1.Value = 0
        ProgressBar1.Maximum = 100
        ProgressBar1.Step = 0
        Timer1.Enabled = True

    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        ProgressBar1.Increment(1)
        Label2.Text = ProgressBar1.Value & ("%")
        If ProgressBar1.Value = 99 Then
            MsgBox("Succes!")
        End If

    End Sub
End Class
 

Tidak ada komentar: