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

📄 form1.frm

📁 文件是用VB开发的,对于初次学习者有借鉴作用,可以提高学习的效率
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "登记"
   ClientHeight    =   6105
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   6810
   LinkTopic       =   "Form1"
   MDIChild        =   -1  'True
   ScaleHeight     =   6105
   ScaleWidth      =   6810
   Begin VB.Frame Frame1 
      Height          =   5535
      Left            =   120
      TabIndex        =   8
      Top             =   480
      Width           =   6495
      Begin VB.CommandButton Command1 
         Caption         =   "确定"
         Height          =   270
         Left            =   600
         TabIndex        =   12
         TabStop         =   0   'False
         Top             =   5160
         Width           =   1095
      End
      Begin VB.CommandButton Command2 
         Caption         =   "取消"
         Height          =   270
         Left            =   3120
         TabIndex        =   11
         TabStop         =   0   'False
         Top             =   5160
         Width           =   1095
      End
      Begin VB.ComboBox Combo1 
         BackColor       =   &H80000018&
         ForeColor       =   &H000000FF&
         Height          =   300
         Index           =   0
         ItemData        =   "Form1.frx":0000
         Left            =   4080
         List            =   "Form1.frx":000A
         TabIndex        =   10
         TabStop         =   0   'False
         Text            =   "Combo1"
         Top             =   360
         Width           =   615
      End
      Begin VB.TextBox Text1 
         Appearance      =   0  'Flat
         BackColor       =   &H80000018&
         ForeColor       =   &H000000FF&
         Height          =   300
         Index           =   0
         Left            =   1320
         MaxLength       =   5
         TabIndex        =   0
         Text            =   "Text1"
         Top             =   405
         Width           =   1095
      End
      Begin VB.TextBox Text1 
         Appearance      =   0  'Flat
         BackColor       =   &H80000018&
         ForeColor       =   &H000000FF&
         Height          =   300
         Index           =   1
         Left            =   1320
         MaxLength       =   8
         TabIndex        =   1
         Text            =   "Text1"
         Top             =   840
         Width           =   1095
      End
      Begin VB.TextBox Text1 
         Appearance      =   0  'Flat
         BackColor       =   &H80000018&
         ForeColor       =   &H000000FF&
         Height          =   300
         Index           =   3
         Left            =   1320
         MaxLength       =   30
         TabIndex        =   3
         Text            =   "Text1"
         Top             =   1740
         Width           =   2895
      End
      Begin VB.TextBox Text1 
         Appearance      =   0  'Flat
         BackColor       =   &H80000018&
         ForeColor       =   &H000000FF&
         Height          =   300
         Index           =   4
         Left            =   1320
         MaxLength       =   6
         TabIndex        =   4
         Text            =   "Text1"
         Top             =   2160
         Width           =   1695
      End
      Begin VB.TextBox Text1 
         Appearance      =   0  'Flat
         BackColor       =   &H80000018&
         ForeColor       =   &H000000FF&
         Height          =   300
         Index           =   5
         Left            =   1320
         MaxLength       =   12
         TabIndex        =   5
         Text            =   "Text1"
         Top             =   2640
         Width           =   1695
      End
      Begin VB.TextBox Text1 
         Appearance      =   0  'Flat
         BackColor       =   &H80000018&
         ForeColor       =   &H000000FF&
         Height          =   300
         Index           =   6
         Left            =   1320
         TabIndex        =   6
         Text            =   "Text1"
         Top             =   3120
         Width           =   1455
      End
      Begin VB.TextBox Text1 
         Appearance      =   0  'Flat
         BackColor       =   &H80000018&
         ForeColor       =   &H000000FF&
         Height          =   1260
         Index           =   7
         Left            =   1320
         MultiLine       =   -1  'True
         ScrollBars      =   2  'Vertical
         TabIndex        =   7
         Text            =   "Form1.frx":0016
         Top             =   3600
         Width           =   4095
      End
      Begin VB.ComboBox Combo1 
         BackColor       =   &H80000018&
         ForeColor       =   &H000000FF&
         Height          =   300
         Index           =   1
         ItemData        =   "Form1.frx":001C
         Left            =   4080
         List            =   "Form1.frx":001E
         TabIndex        =   9
         TabStop         =   0   'False
         Text            =   "Combo1"
         Top             =   840
         Width           =   1095
      End
      Begin VB.TextBox Text1 
         Appearance      =   0  'Flat
         BackColor       =   &H80000018&
         ForeColor       =   &H000000FF&
         Height          =   300
         Index           =   2
         Left            =   1320
         TabIndex        =   2
         Text            =   "Text1"
         Top             =   1245
         Width           =   1575
      End
      Begin VB.Label Label1 
         Caption         =   "学号:"
         Height          =   255
         Index           =   0
         Left            =   720
         TabIndex        =   22
         Top             =   480
         Width           =   615
      End
      Begin VB.Label Label3 
         Caption         =   "性别:"
         Height          =   255
         Left            =   3480
         TabIndex        =   21
         Top             =   480
         Width           =   615
      End
      Begin VB.Label Label4 
         Caption         =   "班级:"
         Height          =   255
         Left            =   3360
         TabIndex        =   20
         Top             =   960
         Width           =   615
      End
      Begin VB.Label Label1 
         Caption         =   "姓名:"
         Height          =   255
         Index           =   1
         Left            =   720
         TabIndex        =   19
         Top             =   960
         Width           =   615
      End
      Begin VB.Label Label1 
         Caption         =   "出生年月:"
         Height          =   255
         Index           =   2
         Left            =   360
         TabIndex        =   18
         Top             =   1320
         Width           =   975
      End
      Begin VB.Label Label1 
         Caption         =   "家庭住址:"
         Height          =   255
         Index           =   3
         Left            =   360
         TabIndex        =   17
         Top             =   1800
         Width           =   975
      End
      Begin VB.Label Label1 
         Caption         =   "邮政编码:"
         Height          =   255
         Index           =   4
         Left            =   360
         TabIndex        =   16
         Top             =   2160
         Width           =   975
      End
      Begin VB.Label Label1 
         Caption         =   "联系电话:"
         Height          =   255
         Index           =   5
         Left            =   360
         TabIndex        =   15
         Top             =   2640
         Width           =   975
      End
      Begin VB.Label Label1 
         Caption         =   "入学时间:"
         Height          =   255
         Index           =   6
         Left            =   360
         TabIndex        =   14
         Top             =   3120
         Width           =   975
      End
      Begin VB.Label Label1 
         Caption         =   "备注:"
         Height          =   255
         Index           =   7
         Left            =   720
         TabIndex        =   13
         Top             =   3600
         Width           =   615
      End
   End
   Begin VB.Label Label10 
      Caption         =   "入学登记"
      BeginProperty Font 
         Name            =   "楷体_GB2312"
         Size            =   18
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   615
      Left            =   2400
      TabIndex        =   23
      Top             =   0
      Width           =   2175
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim txtsql1 As String
Private Sub Combo1_Click(Index As Integer)
Dim mrc As ADODB.Recordset
txtsql1 = "select 专业,年制 from class where 班级='" & Trim(Combo1(1).Text) & "'"
Set mrc = ExecuteSQL(txtsql1)
mrc.Close
End Sub

Private Sub Combo1_KeyPress(Index As Integer, KeyAscii As Integer)
 If KeyAscii = 13 Then

 SendKeys "{TAB}"
 End If
End Sub

Private Sub Command1_Click()
 For j = 0 To 7
   If Text1(j) = "" Then
     ss = MsgBox(Label1(j).Caption & "不能为空!", vbExclamation + vbOKOnly, "警告")
     Text1(j).SetFocus
     Text1(j).SelStart = 0
     Text1(j).SelLength = Len(Text1(j).Text)
    Exit Sub
   End If

Next

Dim mrc As ADODB.Recordset

  txtsql1 = "select * from xj where 学号='" & Trim(Text1(0).Text) & "'"
  Set mrc = ExecuteSQL(txtsql1)
If modi = False Then
  If mrc.EOF = False Then
   sss = MsgBox("已经存在该学号的记录,学号不能重复!", vbExclamation + vbOKOnly, "警告")
   Text1(0).SetFocus
    Text1(0).SelStart = 0
   Text1(0).SelLength = Len(Text1(0).Text)
   mrc.Close
   Exit Sub
 End If
 End If
 
  If Not IsDate(Text1(2).Text) Then '判断是否日期格式
     ssss = MsgBox("应输入日期 mm-dd-yy", vbInformation + vbOKOnly, "警告")
    Text1(2).SetFocus
     Text1(2).SelStart = 0
   Text1(2).SelLength = Len(Text1(2).Text)
    Exit Sub
  End If
  If Not IsDate(Text1(6).Text) Then
     ssss = MsgBox("应输入日期 mm-dd-yy", vbInformation + vbOKOnly, "警告")
    Text1(6).SetFocus
     Text1(6).SelStart = 0
   Text1(6).SelLength = Len(Text1(6).Text)
    Exit Sub
  End If

If modi = True Then

txtsql1 = "update   xj  set 学号='" & Trim(Text1(0).Text) & "',姓名='" & Trim(Text1(1).Text) & "',性别='" & Trim(Combo1(0).Text) & "',班级='" & Trim(Combo1(1).Text) & "',出生年月=#" & Trim(Text1(2).Text) & "# ,家庭住址='" & Trim(Text1(3).Text) & "' ,邮政编码='" & Trim(Text1(4).Text) & "' ,联系电话='" & Trim(Text1(5).Text) & "' ,入学时间=#" & Trim(Text1(6).Text) & "# ,备注='" & Trim(Text1(7).Text) & "'where 学号='" & Trim(Form3.MSF1.TextMatrix(Form3.MSF1.Row, 1)) & "'"
Set mrc = ExecuteSQL(txtsql1)
txtsql1 = "update   cj set 学号='" & Trim(Text1(0).Text) & "' where 学号='" & Trim(Form3.MSF1.TextMatrix(Form3.MSF1.Row, 1)) & "'"
Set mrc = ExecuteSQL(txtsql1)
txtsql1 = "update   jf set 学号='" & Trim(Text1(0).Text) & "' where 学号='" & Trim(Form3.MSF1.TextMatrix(Form3.MSF1.Row, 1)) & "'" 'Set mrc = ExecuteSQL(txtsql1)
Unload Me
Exit Sub
End If

txtsql1 = "select * from xj "

Set mrc = ExecuteSQL(txtsql1)

  mrc.AddNew

 For i = 4 To 9
    mrc.Fields(i) = Text1(i - 2).Text
  Next i
   mrc.Fields(0) = Trim(Text1(0).Text)
   mrc.Fields(1) = Trim(Text1(1).Text)
 
    mrc.Fields(2) = Trim(Combo1(0).Text)
    mrc.Fields(3) = Trim(Combo1(1).Text)
  mrc.Update
  Set mrc = Nothing

 For j = 0 To 7
   Text1(j) = ""
Next
End Sub


Private Sub Command2_Click()
Unload Me
   
End Sub

Private Sub Form_Activate()
Text1(0).SetFocus
Form1.load1
End Sub

Public Sub load1()
Dim mrc As ADODB.Recordset
 txtsql1 = "select DISTINCT 班级 from class order by 班级"
 Set mrc = ExecuteSQL(txtsql1)
 If mrc.EOF Then
  ddd = MsgBox("请先设置班级部署!", "警告")
   mrc.Close
  Exit Sub
 End If
   Combo1(1).Clear
   mrc.MoveFirst
 Do While Not mrc.EOF
   Combo1(1).AddItem mrc.Fields(0)
   mrc.MoveNext
 Loop
     Combo1(1).ListIndex = 0
     Combo1(0).ListIndex = 0
If modi Then  '如果是修改状态
  Me.Caption = "修改"
  txtsql1 = "select * from xj where 学号='" & Trim(Form3.MSF1.TextMatrix(Form3.MSF1.Row, 1)) & "'"
  Set mrc = ExecuteSQL(txtsql1)
  mrc.MoveFirst
  For i = 4 To 9
   Text1(i - 2).Text = mrc.Fields(i)
  Next i
  Text1(0).Text = mrc.Fields(0)
  Text1(1).Text = mrc.Fields(1)
   Combo1(0).Text = mrc.Fields(2)
   Combo1(1).Text = mrc.Fields(3)
 mrc.Close
Else
  Me.Caption = "登记"
  For i = 2 To 7
   Text1(i).Text = ""
  Next i
  Text1(6).Text = Date
  Text1(0).Text = ""
  Text1(1).Text = ""
   
 End If
End Sub

Private Sub Text1_GotFocus(Index As Integer)
 If Index = 6 Then
  
   Text1(6).SelStart = 0
   Text1(6).SelLength = Len(Text1(6).Text)
  
 End If
End Sub

Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
 If KeyAscii = 13 Then

 SendKeys "{TAB}"
 End If
End Sub


⌨️ 快捷键说明

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