📄 分部修改.frm
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{00028C01-0000-0000-0000-000000000046}#1.0#0"; "DBGRID32.OCX"
Begin VB.Form 分部修改
BorderStyle = 0 'None
Caption = "数据修改"
ClientHeight = 7545
ClientLeft = 5700
ClientTop = 5325
ClientWidth = 11925
Icon = "分部修改.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 503
ScaleMode = 3 'Pixel
ScaleWidth = 795
ShowInTaskbar = 0 'False
Begin VB.Timer Timer2
Enabled = 0 'False
Interval = 100
Left = 330
Top = 240
End
Begin VB.Data Data1
Caption = "Data1"
Connect = "Access"
DatabaseName = ""
DefaultCursorType= 0 '缺省游标
DefaultType = 2 '使用 ODBC
Exclusive = 0 'False
Height = 285
Left = 510
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = ""
Top = 7590
Visible = 0 'False
Width = 1275
End
Begin VB.CommandButton Command5
Caption = "返 回"
Height = 315
Left = 10200
TabIndex = 6
Top = 6615
Width = 1395
End
Begin VB.CommandButton Command4
Caption = "最后一条记录"
Height = 315
Left = 8790
TabIndex = 5
Top = 6615
Width = 1395
End
Begin VB.CommandButton Command3
Caption = "下一记录"
Height = 315
Left = 7380
TabIndex = 4
Top = 6615
Width = 1395
End
Begin VB.CommandButton Command2
Caption = "上一记录"
Height = 315
Left = 5970
TabIndex = 3
Top = 6615
Width = 1395
End
Begin VB.CommandButton Command1
Caption = "第一条记录"
Height = 315
Left = 4560
TabIndex = 2
Top = 6615
Width = 1395
End
Begin MSDBGrid.DBGrid DBGrid1
Bindings = "分部修改.frx":0442
Height = 4815
Left = 150
OleObjectBlob = "分部修改.frx":0456
TabIndex = 1
Top = 1410
Width = 11655
End
Begin VB.Timer Timer1
Enabled = 0 'False
Interval = 500
Left = 1230
Top = 120
End
Begin MSComctlLib.StatusBar StatusBar1
Align = 2 'Align Bottom
Height = 345
Left = 0
TabIndex = 7
Top = 7200
Width = 11925
_ExtentX = 21034
_ExtentY = 609
_Version = 393216
BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628}
NumPanels = 4
BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628}
AutoSize = 1
Object.Width = 4339
Picture = "分部修改.frx":19AD
EndProperty
BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628}
AutoSize = 1
Object.Width = 4339
Picture = "分部修改.frx":1B07
EndProperty
BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628}
Alignment = 2
AutoSize = 1
Object.Width = 6103
MinWidth = 4304
Picture = "分部修改.frx":1F59
EndProperty
BeginProperty Panel4 {8E3867AB-8586-11D1-B16A-00C0F0283628}
Alignment = 2
AutoSize = 1
Object.Width = 6103
MinWidth = 4304
Picture = "分部修改.frx":23AB
EndProperty
EndProperty
End
Begin VB.Shape Shape1
BorderColor = &H0000C000&
BorderWidth = 2
FillColor = &H00000040&
Height = 615
Left = 2700
Shape = 4 'Rounded Rectangle
Top = 210
Width = 6225
End
Begin VB.Line Line1
BorderColor = &H80000005&
BorderWidth = 3
X1 = 2
X2 = 800
Y1 = 64
Y2 = 64
End
Begin VB.Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "数 据 修 改"
BeginProperty Font
Name = "隶书"
Size = 26.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 525
Left = 3360
TabIndex = 0
Top = 240
Width = 4785
End
End
Attribute VB_Name = "分部修改"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim N(2) As Integer
Dim Num As Integer
Dim Flag As Integer
Dim Ff As Integer
Dim X, D As Integer
Dim Result As Integer
Private Sub Form_Load()
On Error GoTo Z1
Me.Left = 0: Me.Top = 0
Label1.Caption = 主程序.LabelName
Label1.Left = (Me.ScaleWidth - Label1.Width) / 2
Shape1.Left = (Me.ScaleWidth - Shape1.Width) / 2
Data1.DatabaseName = App.Path + "\" + "db1.mdb"
Data1.RecordSource = 主程序.FileName
Data1.Refresh
Data1.Recordset.MoveLast
Data1.Recordset.MoveFirst
Num = Data1.Recordset.RecordCount
StatusBar1.Panels(1).Text = "记录总数: " & Num
StatusBar1.Panels(2).Text = "当前记录: " & 1
StatusBar1.Panels(3).Text = "今天日期: " & Format(Date, "yyyy 年 m 月 d 日")
StatusBar1.Panels(4).Text = "当前时间: " & Time
Exit Sub
Z1:
StatusBar1.Panels(1).Text = "记录总数: " & 0
StatusBar1.Panels(2).Text = "当前记录: " & 0
StatusBar1.Panels(3).Text = "今天日期: " & Format(Date, "yyyy 年 m 月 d 日")
StatusBar1.Panels(4).Text = "当前时间: " & Time
Timer2.Enabled = True
End Sub
Private Sub Command1_Click()
X = 0
D = D + 1
On Error GoTo Q1
Data1.Recordset.MoveFirst
StatusBar1.Panels(2).Text = "当前记录: " & Data1.Recordset.AbsolutePosition + 1
If D >= 2 Then
Result = MsgBox("已经是第一条记录 ! ", vbExclamation)
End If
Exit Sub
Q1:
Result = MsgBox("数据库中无记录 ! ", vbExclamation)
Ff = 1
End Sub
Private Sub Command2_Click()
X = 0: D = 0
On Error GoTo A1
Data1.Recordset.MovePrevious
StatusBar1.Panels(2).Text = "当前记录: " & Data1.Recordset.AbsolutePosition + 1
If Data1.Recordset.AbsolutePosition <= 0 Then
Result = MsgBox("已经是第一条记录 ! ", vbExclamation)
End If
Exit Sub
A1:
If Num = 0 Then
MsgBox "数据库中无记录 "
Else
Result = MsgBox("已经是第一条记录 ! ", vbExclamation)
End If
End Sub
Private Sub Command3_Click()
X = 0: D = 0
On Error GoTo A1
Data1.Recordset.MoveNext
StatusBar1.Panels(2).Text = "当前记录: " & Data1.Recordset.AbsolutePosition + 1
If Data1.Recordset.AbsolutePosition + 1 = 0 Then
StatusBar1.Panels(2).Text = "当前记录: " & Num
Result = MsgBox("已经是最后一条记录 ! ", vbExclamation)
End If
Exit Sub
A1:
Result = MsgBox("已经是最后一条记录 ! ", vbExclamation)
End Sub
Private Sub Command4_Click()
'On Error GoTo Q1
X = X + 1: D = 0
Data1.Recordset.MoveLast
StatusBar1.Panels(2).Text = "当前记录: " & Data1.Recordset.AbsolutePosition + 1
If X >= 2 Then
StatusBar1.Panels(2).Text = "当前记录: " & Num
Result = MsgBox("已经是最后一条记录 ! ", vbExclamation)
End If
Exit Sub
Q1:
Result = MsgBox("已经是最后一条记录 ! ", vbExclamation)
End Sub
Private Sub Command5_Click()
Unload Me
主程序.Show
End Sub
Private Sub DBGrid1_SelChange(Cancel As Integer)
StatusBar1.Panels(2).Text = "当前记录: " & Data1.Recordset.AbsolutePosition + 1
End Sub
Private Sub DBGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
On Error GoTo S1
StatusBar1.Panels(2).Text = "当前记录: " & Data1.Recordset.AbsolutePosition + 1
N(2) = Data1.Recordset.AbsolutePosition + 1
Num = Data1.Recordset.RecordCount
N(1) = Num
If N(2) < N(1) Then
Flag = 0
Else
Flag = 1
End If
StatusBar1.Panels(1).Text = "记录总数: " & Num
If N(2) < N(1) And Flag = 1 Then
StatusBar1.Panels(2).Text = "当前记录: " & N(1)
Flag = 1
End If
DBGrid1.Columns(6) = DBGrid1.Columns(4) - DBGrid1.Columns(5)
Exit Sub
S1:
End Sub
Private Sub Timer1_Timer()
StatusBar1.Panels(4).Text = "当前时间: " & Time
End Sub
Private Sub Timer2_Timer()
Timer2.Enabled = False
Command1.Enabled = False: Command2.Enabled = False: Command3.Enabled = False: Command4.Enabled = False
MsgBox " 数据库无记录,请输入数据 !", vbExclamation
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -