📄 登录.vb
字号:
Public Class 登录
mports System
Imports System.Date
Imports System.Date.SqlClient
Dim i AsInteger=3
Dim strsql As String
Dim strconn As String
Dim objcommand As SqlClient.SqlCommand
Dim objdr As SqlClient.SqlDataReader
Dim str1, str2 As String
Private Sub 登录_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox1.Focus()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
strconn = "date source=cheng;initial catalog=学生成绩管理系统;use id=sa;password=;"
strsql = "select 用户名,密码from用户表"
objcommand = New SqlClient.SqlCommand(strsql, New SqlClient.SqlConnection(strconn))
objcommand.Connection.Open()
objdr=objcommand.ExecuteReader(CommandBehavior.CloseConnection(strconn)
With objdr
Do While .Read = Ture
str1 = .GetString(0)
str2 = .GetString(1)
If Trim(TextBox1.Text) = Trim(str1) And Trim(TextBox2.Text) = Trim(str2) Then
MessageBox.Show("恭喜登录成功", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
主窗体.Show()
Me.Visible = False
Exit Sub
End If
Loop
End With
i = i - 1
If i = 0 Then
MessageBox.Show("你已经没有登陆机会了,Bye!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Hand)
Me.Close()
Else
MessageBox.Show("登录失败" + "你还有" + Str(i) + "次登录机会", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error)
TextBox1.Text = ""
TextBox2.Text = ""
TextBox1.Focus()
End If
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -