Public Class Form1
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
ProgressBar1.Increment(1)
If ProgressBar1.Value = 100 Then
Me.Hide()
frmlogin.Show()
End If
End Sub
End Class
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
If TextBox1.Text = Nothing Then
MsgBox("You Must Enter The Username!", MsgBoxStyle.Exclamation, "Error!")
End If
If TextBox2.Text = Nothing Then
MsgBox("You Must Enter The Password!", MsgBoxStyle.Exclamation, "Error!")
End If
Dim str As String = "Select Username,Password From Login Where Username='" & TextBox1.Text & "'and Password='" & TextBox2.Text & "'"
Dim da As New SqlDataAdapter(str, con)
Dim ds As New DataSet
da.Fill(ds)
If ds.Tables(0).Rows.Count > 0 Then
Me.Hide()
frmmenu.Show()
Else
MsgBox("Username or Password is incorrect!")
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub frmlogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
con.ConnectionString = "Data Source=localhost;Initial Catalog=CrazyCookie;Integrated Security=True"
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If MsgBox("Do you want to Exit?", MsgBoxStyle.YesNo + MsgBoxStyle.Question + MsgBoxStyle.DefaultButton2, "Exit") = MsgBoxResult.No Then
Return
Else
Me.Close()
Application.Exit()
End If
End Sub
ไม่ปิด timer นิครับ
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
ProgressBar1.Increment(1)
If ProgressBar1.Value => 100 Then
Me.Hide()
frmlogin.Show()
Timer1.enable = false
return
End If
End Sub