Description:
GUI (Graphical User Interface) applications with progress bar events
Progressbar_Doevents.vb
Imports System.Data
Imports System.Data.SqlClient
Public Class Login
Dim i As Integer
Dim con As New SqlConnection
Dim cmd As New SqlCommand
Dim da As New SqlDataAdapter
Dim ds As New DataSet
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ProgressBar1.Value = 0
If i > 1 Then
MsgBox("Please Contact Your Administrator", MsgBoxStyle.Information)
Else
con = New SqlConnection("Data Source=COMPUTER10; Initial Catalog=vb; Integrated security=TRUE")
cmd = New SqlCommand("select * from login where userid='" & TextBox1.Text & "' and pwd='" & TextBox2.Text & "'", con)
da = New SqlDataAdapter(cmd)
da.Fill(ds)
If ds.Tables(0).Rows.Count <> 0 Then
Timer1.Enabled = True
Else
MsgBox("Please check the userID and Password")
TextBox1.Clear()
TextBox2.Clear()
TextBox1.Focus()
End If
i = i + 1
End If
End Sub
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
i = 0
TextBox1.Focus()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
ProgressBar1.Visible = True
If ProgressBar1.Value < 90 Then
ProgressBar1.Value += 5
End If
End Sub
End Class

|