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

📄 studentinfo.frm

📁 带有SQL
💻 FRM
字号:
VERSION 5.00
Begin VB.Form studentinfo 
   Caption         =   "学生基本信息录入"
   ClientHeight    =   9360
   ClientLeft      =   165
   ClientTop       =   765
   ClientWidth     =   8595
   LinkTopic       =   "Form1"
   MDIChild        =   -1  'True
   ScaleHeight     =   9360
   ScaleWidth      =   8595
   Begin VB.Frame Frame1 
      Caption         =   "信息录入表"
      Height          =   8295
      Left            =   360
      TabIndex        =   1
      Top             =   840
      Width           =   7815
      Begin VB.ComboBox Combo3 
         Height          =   300
         Left            =   5160
         Style           =   2  'Dropdown List
         TabIndex        =   28
         Top             =   3720
         Width           =   2295
      End
      Begin VB.ComboBox Combo2 
         Height          =   300
         Left            =   1320
         Style           =   2  'Dropdown List
         TabIndex        =   27
         Top             =   3720
         Width           =   2295
      End
      Begin VB.CommandButton Command3 
         Caption         =   "退出"
         Height          =   495
         Left            =   5760
         TabIndex        =   26
         Top             =   7320
         Width           =   1215
      End
      Begin VB.TextBox Text11 
         Height          =   1215
         Left            =   1320
         MultiLine       =   -1  'True
         ScrollBars      =   2  'Vertical
         TabIndex        =   25
         Top             =   5520
         Width           =   5895
      End
      Begin VB.TextBox Text10 
         Height          =   375
         Left            =   1320
         TabIndex        =   24
         Top             =   4560
         Width           =   2295
      End
      Begin VB.TextBox Text7 
         Height          =   375
         Left            =   5160
         TabIndex        =   23
         Top             =   2880
         Width           =   2295
      End
      Begin VB.TextBox Text6 
         Height          =   375
         Left            =   1320
         TabIndex        =   22
         Top             =   2880
         Width           =   2295
      End
      Begin VB.TextBox Text5 
         Height          =   375
         Left            =   5160
         TabIndex        =   21
         Top             =   2040
         Width           =   2295
      End
      Begin VB.TextBox Text4 
         Height          =   375
         Left            =   1320
         TabIndex        =   20
         Top             =   2040
         Width           =   2295
      End
      Begin VB.TextBox Text3 
         Height          =   375
         Left            =   5160
         TabIndex        =   19
         Top             =   1200
         Width           =   2295
      End
      Begin VB.CommandButton Command2 
         Caption         =   "取消添加"
         Height          =   495
         Left            =   3480
         TabIndex        =   17
         Top             =   7320
         Width           =   1335
      End
      Begin VB.CommandButton Command1 
         Caption         =   "确定添加"
         Default         =   -1  'True
         Height          =   495
         Left            =   1320
         TabIndex        =   16
         Top             =   7320
         Width           =   1215
      End
      Begin VB.ComboBox Combo1 
         Height          =   300
         Left            =   1320
         Style           =   2  'Dropdown List
         TabIndex        =   7
         Top             =   1320
         Width           =   2295
      End
      Begin VB.TextBox Text2 
         Height          =   375
         Left            =   5160
         TabIndex        =   5
         Top             =   480
         Width           =   2295
      End
      Begin VB.TextBox Text1 
         Height          =   390
         Left            =   1320
         TabIndex        =   3
         Top             =   480
         Width           =   2295
      End
      Begin VB.Label Label13 
         AutoSize        =   -1  'True
         Caption         =   "班    别:"
         Height          =   180
         Left            =   4080
         TabIndex        =   18
         Top             =   2160
         Width           =   900
      End
      Begin VB.Label Label12 
         AutoSize        =   -1  'True
         Caption         =   "备注"
         Height          =   180
         Left            =   360
         TabIndex        =   15
         Top             =   6000
         Width           =   360
      End
      Begin VB.Label Label11 
         AutoSize        =   -1  'True
         Caption         =   "床    位:"
         Height          =   180
         Left            =   240
         TabIndex        =   14
         Top             =   4680
         Width           =   900
      End
      Begin VB.Label Label10 
         AutoSize        =   -1  'True
         Caption         =   "居住楼号:"
         Height          =   180
         Left            =   240
         TabIndex        =   13
         Top             =   3840
         Width           =   900
      End
      Begin VB.Label Label9 
         AutoSize        =   -1  'True
         Caption         =   "寝 室 号:"
         Height          =   180
         Left            =   4080
         TabIndex        =   12
         Top             =   3840
         Width           =   900
      End
      Begin VB.Label Label8 
         AutoSize        =   -1  'True
         Caption         =   "政治面貌:"
         Height          =   180
         Left            =   4080
         TabIndex        =   11
         Top             =   3000
         Width           =   900
      End
      Begin VB.Label Label7 
         AutoSize        =   -1  'True
         Caption         =   "电    话:"
         Height          =   180
         Left            =   240
         TabIndex        =   10
         Top             =   3000
         Width           =   900
      End
      Begin VB.Label Label6 
         AutoSize        =   -1  'True
         Caption         =   "年    级:"
         Height          =   180
         Left            =   4080
         TabIndex        =   9
         Top             =   1440
         Width           =   900
      End
      Begin VB.Label Label5 
         AutoSize        =   -1  'True
         Caption         =   "系    别:"
         Height          =   180
         Left            =   240
         TabIndex        =   8
         Top             =   2160
         Width           =   900
      End
      Begin VB.Label Label4 
         AutoSize        =   -1  'True
         Caption         =   "性    别:"
         Height          =   180
         Left            =   240
         TabIndex        =   6
         Top             =   1440
         Width           =   900
      End
      Begin VB.Label Label3 
         AutoSize        =   -1  'True
         Caption         =   "姓    名:"
         Height          =   180
         Left            =   4080
         TabIndex        =   4
         Top             =   600
         Width           =   900
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         Caption         =   "学    号:"
         Height          =   180
         Left            =   240
         TabIndex        =   2
         Top             =   600
         Width           =   900
      End
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "学生基本信息录入"
      BeginProperty Font 
         Name            =   "幼圆"
         Size            =   21.75
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   435
      Left            =   2400
      TabIndex        =   0
      Top             =   240
      Width           =   3600
   End
End
Attribute VB_Name = "studentinfo"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub Command1_Click()
    Dim mrc As ADODB.Recordset
    Dim txtSQL As String
    Dim MsgText As String
    '判断各个输入框中是否为空
    If Me.Text1.Text = "" Then
        MsgBox "请输入学号!", vbOKOnly + vbExclamation, "警告"
        Me.Text1.SetFocus
        Me.Text1.Text = ""
        Exit Sub
    End If
    If Not IsNumeric(Trim(Me.Text1.Text)) Then
               MsgBox "学号必须为数字型!,请重新输入!", vbOKOnly + vbExclamation, "警告"
               Me.Text1.Text = ""
               Me.Text1.SetFocus
               Exit Sub
        End If
    If Me.Text2.Text = "" Then
        MsgBox "请输入姓名!", vbOKOnly + vbExclamation, "警告"
        Me.Text2.SetFocus
        Exit Sub
    End If
    If Me.Combo1.Text = "" Then
        MsgBox "您没有选择性别!", vbOKOnly + vbExclamation, "警告"
        Me.Combo1.SetFocus
        Exit Sub
    End If
    If Me.Text3.Text = "" Then
        MsgBox "请输入年级!", vbOKOnly + vbExclamation, "警告"
        Me.Text3.SetFocus
        Exit Sub
    End If
    If Me.Text4.Text = "" Then
        MsgBox "请输入系别!", vbOKOnly + vbExclamation, "警告"
        Me.Text4.SetFocus
        Exit Sub
    End If
    If Me.Text5.Text = "" Then
        MsgBox "请输入班号!", vbOKOnly + vbExclamation, "警告"
        Me.Text5.SetFocus
        Exit Sub
    End If
    If Me.Text6.Text = "" Then
        MsgBox "请输入该生的联系电话!", vbOKOnly + vbExclamation, "警告"
        Me.Text6.SetFocus
        Exit Sub
    End If
    If Not IsNumeric(Trim(Me.Text6.Text)) Then
               MsgBox "电话必须为数字型!,请重新输入!", vbOKOnly + vbExclamation, "警告"
               Me.Text6.Text = ""
               Me.Text6.SetFocus
               Exit Sub
        End If
   
    If Me.Text7.Text = "" Then
        MsgBox "请输入该生的政治面貌!", vbOKOnly + vbExclamation, "警告"
        Me.Text7.SetFocus
        Exit Sub
    End If
    If Me.Combo2.Text = "" Then
        MsgBox "请选择该生所居住的楼号,如果没有楼号请先添加居住信息!", vbOKOnly + vbExclamation, "警告"
        Me.Combo2.SetFocus
        Exit Sub
    End If
    If Me.Combo3.Text = "" Then
        MsgBox "请选择该生的寝室号,如果没有楼号请先添加居住信息!", vbOKOnly + vbExclamation, "警告"
        Me.Combo3.SetFocus
        Exit Sub
    End If
    If Me.Text10.Text = "" Then
        MsgBox "请输入该生的床位号!", vbOKOnly + vbExclamation, "警告"
        Me.Text10.SetFocus
        Exit Sub
    End If
    '///////////////////////////////////////////////////////////////////////
    If Trim((Len(Me.Text6.Text) = 8) Or (Len(Me.Text6.Text) = 11)) Then      '限制输入数字为8位 或 11位数
       
    '开始查询数据库里的学生的学号是否重复
    txtSQL = "select * from student_if where student_ID = '" & Trim(Me.Text1.Text) & "'"
    Set mrc = ExecuteSQL(txtSQL, MsgText)
    If mrc.EOF = False Then
        MsgBox "这个学号已经有了,请重新输入!", vbOKOnly + vbExclamation, "警告"
        mrc.Close
        Me.Text1.Text = ""
        Me.Text1.SetFocus
    Else
        mrc.Close
        
        txtSQL = "select * from student_if"
        Set mrc = ExecuteSQL(txtSQL, MsgText)
        mrc.AddNew    '添加一条记录
                mrc.Fields(0) = Trim(Me.Text1.Text)
                mrc.Fields(1) = Trim(Me.Text2.Text)
                mrc.Fields(2) = Trim(Me.Combo1.Text)
                mrc.Fields(3) = Trim(Me.Text3.Text)
                mrc.Fields(4) = Trim(Me.Text4.Text)
                mrc.Fields(5) = Trim(Me.Text5.Text)
                mrc.Fields(6) = Trim(Me.Text6.Text)
                mrc.Fields(7) = Trim(Me.Text7.Text)
                mrc.Fields(8) = Trim(Me.Combo2.Text)
                mrc.Fields(9) = Trim(Me.Combo3.Text)
                mrc.Fields(10) = Trim(Me.Text10.Text)
                mrc.Fields(11) = Trim(Me.Text11.Text)
                mrc.Update
                mrc.Close
                
                MsgBox "添加学生基本信息成功!", vbOKOnly + vbExclamation, "提示"
           
               
                '把所有的控件里的内容清空
                Me.Text1.Text = ""
                Me.Text2.Text = ""
                Me.Text3.Text = ""
                Me.Text4.Text = ""
                Me.Text5.Text = ""
                Me.Text6.Text = ""
                Me.Text7.Text = ""
    
                Me.Text10.Text = ""
                Me.Text11.Text = ""
                
         End If
     Else
               MsgBox "不是电话吧???位数只可以为8或11位!", 0, "提示"
               Me.Text6.Text = ""
               Me.Text6.SetFocus
               Exit Sub
    End If
End Sub

Private Sub Command2_Click()
        Me.Text1.Text = ""
        Me.Text2.Text = ""
        Me.Text3.Text = ""
        Me.Text4.Text = ""
        Me.Text5.Text = ""
        Me.Text6.Text = ""
        Me.Text7.Text = ""
        Me.Combo2.Text = ""
        Me.Combo3.Text = ""
        Me.Text10.Text = ""
        Me.Text11.Text = ""
        Me.Text1.SetFocus
End Sub

Private Sub Command3_Click()
    Unload Me
End Sub

Private Sub Form_Load()
    Dim mrc As ADODB.Recordset
    Dim txtSQL As String
    Dim MsgText As String
    Dim i As Integer
    txtSQL = "select * from juzhu_if"
    Set mrc = ExecuteSQL(txtSQL, MsgText)
    
    For i = 1 To mrc.Fields.Count - 1
         If Not mrc.EOF Then
            Me.Combo2.AddItem mrc.Fields(0)
            Me.Combo3.AddItem mrc.Fields(2)
            mrc.MoveNext
         End If
        
    Next i
    
    
    Call loading
   
End Sub

Private Sub loading()
    Me.Combo1.AddItem "男"
    Me.Combo1.AddItem "女"
    Me.Top = 0
    Me.Width = 8595
    Me.Height = 9700
    Me.Left = 0
End Sub


Private Sub Frame1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
      If Button = 2 And Shift Then
        mainForm1.PopupMenu ABC
      End If
End Sub

⌨️ 快捷键说明

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