📄 testform.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form TestForm
Caption = "TestForm"
ClientHeight = 3564
ClientLeft = 48
ClientTop = 336
ClientWidth = 6240
BeginProperty Font
Name = "宋体"
Size = 10.8
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "Form1"
ScaleHeight = 3564
ScaleWidth = 6240
StartUpPosition = 2 '屏幕中心
Begin VB.TextBox Text3
DataSource = "Test"
Height = 372
Left = 2280
TabIndex = 5
Top = 1320
Width = 2772
End
Begin VB.CommandButton Command7
Caption = "&Exit"
Height = 372
Left = 3840
TabIndex = 12
Top = 2400
Width = 1452
End
Begin VB.CommandButton Command6
Caption = "&Update"
Height = 372
Left = 2400
TabIndex = 11
Top = 2400
Width = 1452
End
Begin VB.CommandButton Command5
Caption = "&Modify"
Height = 372
Left = 960
TabIndex = 10
Top = 2400
Width = 1452
End
Begin VB.CommandButton Command4
Caption = "&Last"
Height = 372
Left = 4200
TabIndex = 9
Top = 2040
Width = 1092
End
Begin VB.CommandButton Command3
Caption = "&First"
Height = 372
Left = 3120
TabIndex = 8
Top = 2040
Width = 1092
End
Begin VB.CommandButton Command2
Caption = "&Previous"
Height = 372
Left = 2040
TabIndex = 7
Top = 2040
Width = 1092
End
Begin VB.CommandButton Command1
Caption = "&Next"
Height = 372
Left = 960
TabIndex = 6
Top = 2040
Width = 1092
End
Begin VB.TextBox Text2
DataSource = "Test"
Height = 324
Left = 2280
TabIndex = 3
Top = 840
Width = 2772
End
Begin VB.TextBox Text1
DataSource = "Test"
Height = 324
Left = 2280
TabIndex = 1
Top = 408
Width = 2772
End
Begin MSAdodcLib.Adodc Test
Height = 312
Left = 1800
Top = 3000
Visible = 0 'False
Width = 2532
_ExtentX = 4466
_ExtentY = 550
ConnectMode = 3
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 2
LockType = 3
CommandType = 2
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 3
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "DSN=PmData"
OLEDBString = ""
OLEDBFile = ""
DataSourceName = "PmData"
OtherAttributes = ""
UserName = "Admin"
Password = ""
RecordSource = "DataG"
Caption = "Test Ado Data"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 10.8
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "FileType"
Height = 216
Left = 1200
TabIndex = 4
Top = 1440
Width = 864
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "文件编号"
Height = 216
Left = 1200
TabIndex = 2
Top = 960
Width = 864
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "档号"
Height = 216
Left = 1200
TabIndex = 0
Top = 480
Width = 432
End
End
Attribute VB_Name = "TestForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim adoCon As ADODB.Connection
Dim adoRst As ADODB.Recordset
Dim adoCom As ADODB.Command
Private Sub Command1_Click()
With adoRst
If Not .EOF Then
.MoveNext
If Not .EOF Then
Call LoadData
Else
.MoveLast
End If
End If
End With
End Sub
Private Sub Command2_Click()
With adoRst
If Not .BOF Then
.MovePrevious
If Not .BOF Then
Call LoadData
Else
.MoveFirst
End If
End If
End With
End Sub
Private Sub Command3_Click()
adoRst.MoveFirst
Call LoadData
End Sub
Private Sub Command4_Click()
adoRst.MoveLast
Call LoadData
End Sub
Private Sub Command5_Click()
Call SetEnable(True)
Text1.SetFocus
End Sub
Private Sub Command6_Click()
adoRst.Fields("档号") = ConvertNull(Text1.Text)
adoRst.Fields("文件编号") = ConvertNull(Text2.Text)
adoRst.Fields("FileType") = ConvertNull(Text3.Text)
adoRst.Update
End Sub
Private Sub Command7_Click()
adoRst.Close
TestForm.Hide
Unload TestForm
End
End Sub
Private Sub Form_Load()
Set adoCon = New ADODB.Connection
Set adoRst = New ADODB.Recordset
Set adoCom = New ADODB.Command
adoCon.Open "PmData", "", ""
adoCon.CursorLocation = adUseClient
Set adoRst.ActiveConnection = adoCon
adoRst.LockType = adLockOptimistic
adoRst.CursorType = adOpenDynamic
adoRst.Open "Select * From DataG Order By 档号"
Call SetEnable(False)
Call LoadData
End Sub
Private Sub LoadData()
Text1.Text = ConvertNull(adoRst!档号)
Text2.Text = ConvertNull(adoRst!文件编号)
Text3.Text = ConvertNull(adoRst!FileType)
End Sub
Private Sub SetEnable(T_F As Boolean)
Text1.Enabled = T_F
Text2.Enabled = T_F
Text3.Enabled = T_F
End Sub
Private Function ConvertNull(para_Value As Variant) As Variant
If IsNull(para_Value) = True Then
ConvertNull = ""
Else
ConvertNull = para_Value
End If
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -