|
Progressbar in vb.net is a very cool way to display the user the progress of an ongoing activity. Basically it is a very good idea to display the user the progress of an ongoing background activity with the progressbar in vb.net like connecting to the database, looking up a user from the large database table.
In this example of progressbar in vb.net, we are going to check a username and a password to open a second vb.net form or display an error message to the user.
First of all create a new project in VB.Net, design a form and then place three labels, two text boxes, a progressbar, a timer and a button control as shown in the image. You can learn about form designing and CRUD Operations in vb.net using stored procedure in vb.net. Now,change interval properties of timer control to whatever you like keeping in mind that the time is in milli seconds. Now, type the following code on the button click event and Timers tick event.
Happy coding:)
First of all create a new project in VB.Net, design a form and then place three labels, two text boxes, a progressbar, a timer and a button control as shown in the image. You can learn about form designing and CRUD Operations in vb.net using stored procedure in vb.net. Now,change interval properties of timer control to whatever you like keeping in mind that the time is in milli seconds. Now, type the following code on the button click event and Timers tick event.
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Enabled = True
End Sub
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 " & TextBox1.Text, MsgBoxStyle.Information, "Progressbar")
Me.Hide()
Form2.Show()
ProgressBar1.Value = 0
Label1.Text = ""
TextBox1.Clear()
TextBox2.Clear()
TextBox1.Focus()
Else
MsgBox("Sorry username or password is incorrect", MsgBoxStyle.Exclamation, "Progressbar")
TextBox1.Clear()
TextBox2.Clear()
TextBox1.Focus()
ProgressBar1.Value = 0
Label1.Text = ""
End If
End If
End Sub
End Class
You can also change the style properties of progressbar control to Blocks,continuous or marquee.
Finally run the project by pressing F5 and see how Progressbar in vb.networks. You can also check out this Tutorial on Visual Basic Progress Bar control. Happy coding:)
0 comments:
Post a Comment