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

📄 frmadd.frm

📁 用VB实现的小型信息系统课程设计,希望对大家有帮助
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmAdd 
   Caption         =   "添加记录"
   ClientHeight    =   5535
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   6570
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   5535
   ScaleWidth      =   6570
   StartUpPosition =   3  '窗口缺省
   Begin VB.TextBox Text6 
      Height          =   375
      Left            =   4560
      TabIndex        =   15
      Top             =   840
      Width           =   1095
   End
   Begin VB.Data Data1 
      Caption         =   "Data1"
      Connect         =   "Access"
      DatabaseName    =   "C:\Downloads\1950179207\1950179207\Database\Server.mdb"
      DefaultCursorType=   0  '缺省游标
      DefaultType     =   2  '使用 ODBC
      Exclusive       =   0   'False
      Height          =   375
      Left            =   4440
      Options         =   0
      ReadOnly        =   0   'False
      RecordsetType   =   1  'Dynaset
      RecordSource    =   "Stu1"
      Top             =   240
      Visible         =   0   'False
      Width           =   1695
   End
   Begin VB.CommandButton Command2 
      Caption         =   "取消"
      Height          =   375
      Left            =   3720
      TabIndex        =   14
      Top             =   4800
      Width           =   1215
   End
   Begin VB.CommandButton Command1 
      Caption         =   "添加记录"
      Height          =   375
      Left            =   1560
      TabIndex        =   13
      Top             =   4800
      Width           =   1215
   End
   Begin VB.TextBox Text1 
      Height          =   375
      Left            =   1440
      TabIndex        =   0
      Top             =   840
      Width           =   1215
   End
   Begin VB.TextBox Text2 
      Height          =   375
      Left            =   1440
      TabIndex        =   1
      Top             =   1560
      Width           =   1215
   End
   Begin VB.TextBox Text3 
      Height          =   375
      Left            =   1440
      TabIndex        =   2
      Top             =   2280
      Width           =   1215
   End
   Begin VB.TextBox Text4 
      Height          =   375
      Left            =   4560
      TabIndex        =   3
      Top             =   2280
      Width           =   1095
   End
   Begin VB.TextBox Text5 
      Height          =   375
      Left            =   1440
      TabIndex        =   4
      Top             =   3000
      Width           =   1935
   End
   Begin VB.TextBox Text7 
      Height          =   375
      Left            =   1440
      TabIndex        =   6
      Top             =   3720
      Width           =   3975
   End
   Begin VB.Label Label7 
      AutoSize        =   -1  'True
      Caption         =   "所属社团号:"
      Height          =   180
      Left            =   3360
      TabIndex        =   16
      Top             =   840
      Width           =   1080
   End
   Begin VB.Label Label1 
      BackStyle       =   0  'Transparent
      Caption         =   "添加记录"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   15.75
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00000000&
      Height          =   375
      Left            =   2280
      TabIndex        =   12
      Top             =   360
      Width           =   1455
   End
   Begin VB.Label Label2 
      AutoSize        =   -1  'True
      Caption         =   "编号:"
      Height          =   180
      Left            =   720
      TabIndex        =   11
      Top             =   840
      Width           =   540
   End
   Begin VB.Label Label3 
      AutoSize        =   -1  'True
      Caption         =   "姓名:"
      Height          =   180
      Left            =   720
      TabIndex        =   10
      Top             =   1560
      Width           =   540
   End
   Begin VB.Label Label4 
      AutoSize        =   -1  'True
      Caption         =   "年龄:"
      Height          =   180
      Left            =   720
      TabIndex        =   9
      Top             =   2280
      Width           =   540
   End
   Begin VB.Label Label5 
      AutoSize        =   -1  'True
      Caption         =   "  性别:"
      Height          =   180
      Left            =   3720
      TabIndex        =   8
      Top             =   2280
      Width           =   720
   End
   Begin VB.Label Label6 
      AutoSize        =   -1  'True
      Caption         =   "电话:"
      Height          =   180
      Left            =   720
      TabIndex        =   7
      Top             =   3000
      Width           =   540
   End
   Begin VB.Label Label8 
      AutoSize        =   -1  'True
      Caption         =   "身份证号:"
      Height          =   180
      Left            =   360
      TabIndex        =   5
      Top             =   3720
      Width           =   900
   End
End
Attribute VB_Name = "frmAdd"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
  Dim StrId As String
  StrId = Me.Text1.Text
  Me.Data1.Recordset.FindFirst "Id=" & "'" & StrId & "'"
  If Me.Data1.Recordset.NoMatch Then
    Me.Data1.Recordset.AddNew
    Me.Data1.Recordset.Fields("Id").Value = StrId
    Me.Data1.Recordset.Fields("Name").Value = Me.Text2.Text
    Me.Data1.Recordset.Fields("age").Value = Me.Text3.Text
    Me.Data1.Recordset.Fields("Sex").Value = Me.Text4.Text
    Me.Data1.Recordset.Fields("Phone").Value = Me.Text5.Text
    Me.Data1.Recordset.Fields("suoshu").Value = Me.Text6.Text
    Me.Data1.Recordset.Fields("shenfen").Value = Me.Text7.Text
    Me.Data1.Recordset.Update
    
    MsgBox "添加记录成功!!!", vbOKOnly + vbInformation, "提示"
    frmMain.Data1.Refresh
    
    Unload Me
  Else
    MsgBox "编号重复!!!", vbOKOnly + vbCritical, "提示"
    Me.Text1.Text = ""
  End If
End Sub

Private Sub Command2_Click()
Unload Me
End Sub

Private Sub Form_Load()
  Me.Data1.DatabaseName = VB.App.Path & "\Database\Server.mdb"
 
  Me.Command1.Enabled = False
End Sub

Private Sub Text1_Change()
  Me.Command1.Enabled = True
End Sub


⌨️ 快捷键说明

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