How to use Progress bar and Timer in Visual Basic.Net.


In this article I am going to show you how you can use Progress bar in your Visual Basic.Net project and add some cool stuff in your security form of your VB.Net project. You can validate your username and password after the Progress bar's value reaches 100 and then you will be notified whether the username and password matches or not. The label is also showing the progress of the Progress bar by displaying percentage completed. The design of the form is shown in the image.

In this article I am going to show you how you can use Progress bar in your Visual Basic.Net project and add some cool stuff in your security form of your VB.Net project.
First start a new project and form 1 will be added to your project.Now, add a Progress bar, Two Text Boxes, Two Buttons, One Timer and Three Labels as shown in the image and set timer enable property to false and text property of label1 to "".
Add the following code on the click event of button 1


Timer1.Enabled = True

Add the following code on the click event of button 2

end

Add the following code on the Load event of Form 1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ProgressBar1.Minimum = 0
ProgressBar1.Maximum = 100

End Sub


Finally add the following code on the timer's Tick event.

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
ProgressBar1.Value = ProgressBar1.Value + 1
Label1.Text = ProgressBar1.Value & " % " & " completed"
If ProgressBar1.Value >= 100 Then
Timer1.Enabled = False
If TextBox1.Text = "admin" And TextBox2.Text = "admin" Then
MsgBox("Welcome", MsgBoxStyle.Information, "Sarfaraz")
ProgressBar1.Value = 0

Else
MsgBox("Invalid username or password", MsgBoxStyle.Information, "Sarfaraz")
Label1.Text = ""
ProgressBar1.Value = 0
TextBox1.Focus()
End If


End If
End Sub



Progress bar in Visual Basic.Net


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: