📄 新用户注册.frm
字号:
VERSION 5.00
Begin VB.Form 新用户注册
Caption = "新用户注册"
ClientHeight = 3135
ClientLeft = 60
ClientTop = 450
ClientWidth = 4155
LinkTopic = "Form1"
ScaleHeight = 3135
ScaleWidth = 4155
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton Command2
Caption = "退出"
Height = 495
Left = 2160
TabIndex = 5
Top = 1920
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "注册"
Height = 495
Left = 720
TabIndex = 4
Top = 1920
Width = 1215
End
Begin VB.TextBox Text2
Height = 375
Left = 1920
TabIndex = 3
Top = 1200
Width = 1455
End
Begin VB.TextBox Text1
Height = 375
Left = 1920
TabIndex = 1
Top = 600
Width = 1455
End
Begin VB.Label Label2
Caption = "密码:"
Height = 255
Left = 840
TabIndex = 2
Top = 1320
Width = 615
End
Begin VB.Label Label1
Caption = "用户名:"
Height = 255
Left = 720
TabIndex = 0
Top = 720
Width = 735
End
End
Attribute VB_Name = "新用户注册"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Command1_Click()
'以下代码用于出错处理
Dim MsgText As String
Dim sMeg As String
If Text1.Text = "" Then
sMeg = " 用户名不能为空"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
Text1.SetFocus
Exit Sub
Else
'Dim str As String
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim sSQL As String
Dim sOut As String
Dim Count As Integer
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
' Set properties of the Connection.
cn.ConnectionString = "DSN=成绩查询;UID=sa;PWD=sa;"
cn.ConnectionTimeout = 30
cn.Open
sSQL = "SELECT * FROM admin where 用户=" & Text1.Text & ""
Set rs = cn.Execute(sSQL)
If Not rs.BOF And Not rs.EOF Then
MsgBox "该用户名已存在!请重新输入!", vbOKOnly + vbExclamation, "警告"
Text1.Text = ""
Exit Sub
End If
End If
If Text2.Text = "" Then
MsgBox "密码不能为空,请重填!", vbOKOnly, "输入错误"
Exit Sub
End If
cn.Execute "insert into admin (用户,密码) values(" & Text1.Text & ",'" & Text2.Text & "') "
MsgBox "用户注册成功!", vbOKOnly, "用户注册成功"
Text1.Text = ""
Text2.Text = ""
cn.Close
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -