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

📄 form4.frm

📁 为一个单位的老师写的小工具
💻 FRM
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "msadodc.ocx"
Begin VB.Form Form4 
   Caption         =   "录入"
   ClientHeight    =   9090
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   11220
   LinkTopic       =   "Form4"
   ScaleHeight     =   9090
   ScaleWidth      =   11220
   StartUpPosition =   3  'Windows Default
   Begin MSAdodcLib.Adodc Adodc1 
      Height          =   615
      Left            =   8160
      Top             =   6120
      Visible         =   0   'False
      Width           =   2535
      _ExtentX        =   4471
      _ExtentY        =   1085
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "Adodc1"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin VB.TextBox txtFields 
      DataField       =   "ID"
      DataSource      =   "datPrimaryRS"
      Height          =   285
      Index           =   0
      Left            =   2280
      TabIndex        =   11
      Top             =   600
      Width           =   3735
   End
   Begin VB.CommandButton Command2 
      Caption         =   "清除"
      Height          =   495
      Left            =   6480
      TabIndex        =   10
      Top             =   600
      Width           =   975
   End
   Begin MSAdodcLib.Adodc Adodc2 
      Height          =   330
      Left            =   8280
      Top             =   7320
      Visible         =   0   'False
      Width           =   1815
      _ExtentX        =   3201
      _ExtentY        =   582
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "Adodc2"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin VB.Frame Frame3 
      Caption         =   "添加"
      Height          =   2535
      Left            =   7560
      TabIndex        =   6
      Top             =   600
      Width           =   3375
      Begin VB.CommandButton Command6 
         Caption         =   "开始添加"
         Height          =   495
         Left            =   240
         TabIndex        =   9
         Top             =   240
         Width           =   1695
      End
      Begin VB.CommandButton Command1 
         Caption         =   "确认添加"
         Height          =   495
         Left            =   240
         TabIndex        =   8
         Top             =   1440
         Width           =   1695
      End
      Begin VB.CommandButton Command3 
         Caption         =   "结束添加"
         Height          =   495
         Left            =   240
         TabIndex        =   7
         Top             =   840
         Width           =   1695
      End
   End
   Begin VB.Frame Frame2 
      Caption         =   "即时修改"
      Height          =   2295
      Left            =   7560
      TabIndex        =   0
      Top             =   3360
      Width           =   3375
      Begin VB.CommandButton Command5 
         Caption         =   "执行修改"
         Enabled         =   0   'False
         Height          =   495
         Left            =   360
         TabIndex        =   5
         Top             =   1080
         Width           =   2535
      End
      Begin VB.CommandButton Command4 
         Caption         =   ">|"
         Height          =   495
         Index           =   3
         Left            =   2520
         TabIndex        =   4
         Top             =   360
         Width           =   375
      End
      Begin VB.CommandButton Command4 
         Caption         =   "->"
         Height          =   495
         Index           =   2
         Left            =   1680
         TabIndex        =   3
         Top             =   360
         Width           =   855
      End
      Begin VB.CommandButton Command4 
         Caption         =   "<-"
         Height          =   495
         Index           =   1
         Left            =   840
         TabIndex        =   2
         Top             =   360
         Width           =   855
      End
      Begin VB.CommandButton Command4 
         Caption         =   "|<"
         Height          =   495
         Index           =   0
         Left            =   360
         TabIndex        =   1
         Top             =   360
         Width           =   495
      End
   End
   Begin VB.Label lblLabels 
      Caption         =   "姓名:"
      Height          =   255
      Index           =   0
      Left            =   360
      TabIndex        =   12
      Top             =   600
      Width           =   1815
   End
End
Attribute VB_Name = "Form4"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim id As String
Dim cMAx As Integer
Dim flagEdit As Boolean

Private Sub Command1_Click()
'每一次确认,都会为下一次准备继续
 '防止出错误!
   
  flagEdit = True
   Command5.Enabled = False
 On Error GoTo AddErr
   '一种保护
   Command5.Enabled = False
   
   '数据库操作
   
   Adodc1.Refresh
   
   Adodc1.Recordset.AddNew
   
   For i = 0 To cMAx - 1
     Adodc1.Recordset.Fields(i) = Trim(txtFields(i).Text)
   Next i
   Adodc1.Recordset.Update
    
   
  
  
  '新一轮的添加
  
  '生成新id
  
  Dim DIindex As Integer
   For i = 0 To cMAx - 1
       If Trim(lblLabels(i)) = "ID" & ":" Then
        idindex = i
       End If
   Next
  
   
  '清除
   
    
  id = txtFields(idindex).Text
  For i = 0 To cMAx - 1
      txtFields(i).Text = ""
  Next i
  id = Val(id) + 1
  txtFields(idindex).Text = id
 
 
 
 GoTo sss
AddErr:
     MsgBox Err.Description
sss:
End Sub

Private Sub Command2_Click()
   For i = 0 To cMAx - 1
    txtFields(i).Text = ""
   Next i
End Sub

Private Sub Command3_Click()
  Unload Me
End Sub
Private Sub Command4_Click(Index As Integer)
 '前后移动记录
  
  With Adodc1.Recordset
     Select Case Index
       Case 0:
         If Not .BOF Then .MoveFirst
         If .BOF Then .MoveFirst
         
       Case 1:
         If .RecordCount > 0 Then
            If Not .BOF Then .MovePrevious
            If .BOF Then .MoveFirst
         End If
       Case 2:
        If .RecordCount > 0 Then
           If Not .EOF Then .MoveNext
           If .EOF Then .MoveLast
        End If
       Case 3:
        If .RecordCount > 0 Then
           If Not .EOF Then .MoveLast
           If .EOF Then .MoveLast
        End If
     End Select
   End With
  '显示一下
   For i = 0 To cMAx - 1
     If Adodc1.Recordset.Fields(i) <> "" Then
        txtFields(i).Text = Trim(Adodc1.Recordset.Fields(i))
     End If
   Next i
           
   Command5.Enabled = True
   
         
           


End Sub

 

Private Sub Command5_Click()
   
On Error GoTo e
   For i = 0 To cMAx - 1
     Adodc1.Recordset.Fields(i) = Trim(txtFields(i).Text)
   Next i
   Adodc1.Recordset.Update
   'Adodc1.Refresh
GoTo X
e:
  MsgBox Err.Description
X:
End Sub

Private Sub Command6_Click()
   '开始添加操作
   
   '一种保护
   Command5.Enabled = False
   
  '清除显示
   For i = 0 To cMAx - 1
     txtFields(i).Text = ""
   Next i
   
   '得到推荐的id
   If id = 0 Then
     Adodc1.RecordSource = "select id from tblC "
     Adodc1.Refresh
     a = Adodc1.Recordset.Fields(0)
     txtFields(1).Text = Val(a) + 1
   Else
     txtFields(1).Text = Val(id)
   End If
   
   Adodc1.CommandType = adCmdText
   Adodc1.RecordSource = "select * from tblXUESHENG "
   Adodc1.Refresh
End Sub

Private Sub Form_Load()
   Dim a As Integer
   Me.Left = (Screen.Width - Me.Width) / 2 + 150   '使窗体居中
   Me.Top = (Screen.Height - Me.Height) / 2 + 100
flagEdit = False
   
   Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\招聘信息.mdb;Persist Security Info=False"
   
   '生成录入的序号
   Adodc1.RecordSource = "select id from   tblC  "
   Adodc1.Refresh
   a = Val(Adodc1.Recordset.Fields(0))
   Adodc1.CommandType = adCmdText
   Adodc1.RecordSource = "select * from tblXUESHENG "
   Adodc1.Refresh
   
   '防止出错误!
   Command5.Enabled = False
   
   
    Adodc2.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\招聘信息.mdb;Persist Security Info=False"
    Adodc2.RecordSource = "select  c   from tblC   "
    Adodc2.Refresh
    cMAx = Adodc2.Recordset.Fields(0)
  
    Adodc2.RecordSource = "select  名称   from tblCol   "
    Adodc2.Refresh
   
   
   '为了大小一至
   lblLabels(0).Top = txtFields(0).Top
   lblLabels(0).Height = txtFields(0).Height
   
   lblLabels(0).Caption = Trim(Adodc2.Recordset.Fields(0)) & ":"
  
   'if trim(Adodc2.Recordset.Fields(0))="ID"
   
    Dim i As Integer
    
    For i = 1 To cMAx - 1
        
        Load txtFields(i)
        txtFields(i).Left = txtFields(i - 1).Left
        txtFields(i).Top = txtFields(i - 1).Top + txtFields(i - 1).Height + 25
        txtFields(i).Visible = True
        '
        
         
        Load lblLabels(i)
        lblLabels(i).Left = lblLabels(i - 1).Left
        lblLabels(i).Top = lblLabels(i - 1).Top + lblLabels(i - 1).Height + 25
        
        Adodc2.Recordset.MoveNext
        lblLabels(i).Caption = Adodc2.Recordset.Fields(0) & ":"
        lblLabels(i).Visible = True
    
    Next
    
     For i = 0 To cMAx - 1
       If Trim(lblLabels(i)) = "ID" & ":" Then
        txtFields(i).Text = a + 1
       End If
     Next
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
   
   
End Sub

Private Sub Form_Unload(Cancel As Integer)
If flagEdit Then
    Dim i As Integer
    Dim id As String
  Dim DIindex As Integer
   For i = 0 To cMAx - 1
       If Trim(lblLabels(i)) = "ID" & ":" Then
        idindex = i
       End If
   Next
    id = txtFields(idindex).Text
 
 'id=id-1
 '不用这一句 每一批的添加序号都会空出一个!
 
   Adodc1.RecordSource = "select id from   tblC  "
   Adodc1.Refresh
   Adodc1.Recordset.Fields(0) = Trim(id)
   Adodc1.Recordset.Update
End If
End Sub

⌨️ 快捷键说明

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