📄 登陆界面.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3225
ClientLeft = 60
ClientTop = 345
ClientWidth = 5130
ForeColor = &H00C0C000&
Icon = "登陆界面.frx":0000
LinkTopic = "Form1"
ScaleHeight = 3225
ScaleWidth = 5130
StartUpPosition = 3 '窗口缺省
Begin VB.Frame Frame1
Caption = "Frame1"
Height = 3495
Left = -120
TabIndex = 0
Top = -240
Width = 5295
Begin VB.CommandButton command2
Caption = "取消"
Height = 375
Left = 2040
TabIndex = 8
Top = 2640
Width = 1095
End
Begin VB.CommandButton command3
Caption = "退出"
Height = 375
Left = 3720
TabIndex = 7
Top = 2640
Width = 1215
End
Begin VB.CommandButton command1
Caption = "登陆"
Height = 375
Left = 360
TabIndex = 6
Top = 2640
Width = 1095
End
Begin VB.TextBox text2
Height = 375
Left = 1680
TabIndex = 5
Text = "Text2"
Top = 1800
Width = 2055
End
Begin VB.TextBox text1
Height = 390
Left = 1680
TabIndex = 3
Text = "Text1"
Top = 1080
Width = 2055
End
Begin VB.Label Label3
Caption = "登陆密码"
Height = 255
Left = 600
TabIndex = 4
Top = 1800
Width = 855
End
Begin VB.Label Label2
Caption = "登陆名"
Height = 255
Left = 600
TabIndex = 2
Top = 1200
Width = 615
End
Begin VB.Label Label1
Caption = "学生数据库管理系统"
BeginProperty Font
Name = "宋体"
Size = 21.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = -1 'True
Strikethrough = 0 'False
EndProperty
ForeColor = &H00808000&
Height = 495
Left = 600
TabIndex = 1
Top = 360
Width = 3975
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public ConStr As String
Private Sub Command1_Click()
If IsNAMELegit(Text1.Text) Then
Dim recd As ADODB.Recordset
Dim Source As String
Set recd = New ADODB.Recordset
Source = "Select 登陆密码 from 登陆 where 登陆名='" & Text1.Text & "'"
recd.Open Source, ConStr, adOpenForwardOnly, adLockReadOnly
If recd.BOF And recd.EOF Then
MsgBox "请输入正确登陆名", vbInformation, "提示"
Else
If recd.Fields("登陆密码").Value = Text2.Text Then
MDIForm1.Enabled = True
MDIForm1.Visible = True
'进入系统
Unload Me
Else
MsgBox "密码错误", vbInformation, "提示"
Text2 = ""
End If
End If
Else
End If
End Sub
Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
End Sub
Private Sub Command3_Click()
End
End Sub
Private Sub Form_Load()
ConStr = "Provider=SQLOLEDB.1;Password=315613;Persist Security Info=True;User ID=sa;Initial Catalog=wt;Data Source=wt"
Text1.Text = ""
Text2.Text = ""
Text2.PasswordChar = "*"
End Sub
Public Function GetNumString(ByVal num As Integer, ByVal length As Integer, ByRef str As String) As Boolean
'输入数字和字符串的长度,得到定长的字符串
str = ""
If num < 0 Or length < 0 Then
GetNumString = False
Exit Function
End If
str = num
If Len(str) > length Then
str = ""
GetNumString = False
Exit Function
End If
While Len(str) < length
str = str & "0"
Wend
GetNumString = True
End Function
Public Function IsNAMELegit(ByVal str As String) As Boolean
'检查输入的字符串是否存在恶意攻击SQL
If InStr(1, str, "'", vbTextCompare) Or Len(str) = 0 Or InStr(1, str, "%", vbTextCompare) Or InStr(1, str, "*", vbTextCompare) Then
IsNAMELegit = False
Exit Function
End If
IsNAMELegit = True
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -