⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form4.frm

📁 学生管理系统:包括查询
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form4 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "添加用户"
   ClientHeight    =   5640
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   6390
   BeginProperty Font 
      Name            =   "宋体"
      Size            =   15
      Charset         =   134
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   LinkTopic       =   "Form4"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   5640
   ScaleWidth      =   6390
   Begin VB.CommandButton Command2 
      Caption         =   "退出"
      Height          =   975
      Left            =   3120
      TabIndex        =   7
      Top             =   4320
      Width           =   1815
   End
   Begin VB.CommandButton Command1 
      Caption         =   "确认"
      Height          =   975
      Left            =   600
      TabIndex        =   6
      Top             =   4320
      Width           =   1575
   End
   Begin VB.TextBox Text3 
      Height          =   975
      Left            =   2160
      TabIndex        =   5
      Top             =   2880
      Width           =   2415
   End
   Begin VB.TextBox Text2 
      Height          =   975
      Left            =   2160
      TabIndex        =   3
      Top             =   1560
      Width           =   2415
   End
   Begin VB.TextBox Text1 
      Height          =   855
      Left            =   2160
      TabIndex        =   1
      Top             =   360
      Width           =   2415
   End
   Begin VB.Label Label3 
      BackStyle       =   0  'Transparent
      Caption         =   "请确认密码:"
      Height          =   1095
      Left            =   240
      TabIndex        =   4
      Top             =   3120
      Width           =   2055
   End
   Begin VB.Label Label2 
      BackStyle       =   0  'Transparent
      Caption         =   "请输入密码:"
      Height          =   1215
      Left            =   240
      TabIndex        =   2
      Top             =   1920
      Width           =   2055
   End
   Begin VB.Label Label1 
      BackStyle       =   0  'Transparent
      Caption         =   "请输入用户名:"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   615
      Left            =   240
      TabIndex        =   0
      Top             =   480
      Width           =   2055
   End
   Begin VB.Image Image1 
      Height          =   5655
      Left            =   0
      Picture         =   "Form4.frx":0000
      Stretch         =   -1  'True
      Top             =   0
      Width           =   6375
   End
End
Attribute VB_Name = "Form4"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim conn As New ADODB.Connection
Dim mrc As New ADODB.Recordset
Private Sub Command1_Click()
Dim txtsql As String
If Trim(Text1.Text) = "" Then
   MsgBox "请输入用户名称!", vbExclamation, "警告"
   Exit Sub
Else
   txtsql = "select * from 用户表 "
  Set mrc = executesql(txtsql)
   While (mrc.EOF = False)
      If Trim(mrc.Fields(0)) = Trim(Text1.Text) Then
      MsgBox "用户已经存在,请重新输入!", , "警告"
       Exit Sub
       Else
         mrc.MoveNext
       End If
    Wend
End If
   
If Trim(Text2.Text) <> Trim(Text3.Text) Then
   MsgBox "两次输入密码不一样 请确认!", , "警告"
   Exit Sub
  Else
   If Text2.Text = "" Then
      MsgBox "密码不能为空!", vbExclamation, "警告"
   Else
      mrc.AddNew
      mrc.Fields(0) = Trim(Text1.Text)
      mrc.Fields(1) = Trim(Text2.Text)
      mrc.Update
    MsgBox "添加用户成功!", , "添加用户"
    End If
 End If
 
 Text1.Text = ""
 
 Text2.Text = ""
 Text3.Text = ""
End Sub

Public Function executesql(ByVal sql As String) As ADODB.Recordset
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Set cnn = New ADODB.Connection
Dim stokens() As String
stokens = Split(sql)
cnn.Open "Provider = Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\student.mdb"
If InStr(" INSERT,DELETE,UPDATE", UCase$(stokens(0))) Then
cnn.Execute sql
Else
Set rst = New ADODB.Recordset
rst.Open Trim$(sql), cnn, adOpenKeyset, adLockOptimistic
Set executesql = rst
End If

End Function

Private Sub Command2_Click()
Me.Hide
End Sub

Private Sub Form_Load()
connstr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\student.mdb"
conn.Open connstr
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -