?? addsform.frm
字號(hào):
VERSION 5.00
Begin VB.Form AddSForm
Caption = "添加特殊項(xiàng)"
ClientHeight = 4590
ClientLeft = 6915
ClientTop = 4455
ClientWidth = 3915
LinkTopic = "Form1"
ScaleHeight = 4590
ScaleWidth = 3915
Begin VB.ComboBox cmbID
Height = 315
Left = 1200
TabIndex = 11
Text = "Combo2"
Top = 120
Visible = 0 'False
Width = 2415
End
Begin VB.ComboBox cmbName
Height = 315
Left = 1350
TabIndex = 9
Text = "Combo1"
Top = 510
Width = 2415
End
Begin VB.CommandButton cmdCancel
Caption = "取消"
Height = 375
Left = 1920
TabIndex = 7
Top = 3720
Width = 1095
End
Begin VB.CommandButton cmdAdd
Caption = "添加"
Height = 375
Left = 360
TabIndex = 6
Top = 3720
Width = 1095
End
Begin VB.TextBox txtValue
Height = 375
Index = 4
Left = 1350
TabIndex = 5
Top = 2715
Width = 2415
End
Begin VB.TextBox txtValue
Height = 375
Index = 3
Left = 1350
TabIndex = 3
Top = 2010
Width = 2415
End
Begin VB.TextBox txtValue
Height = 375
Index = 2
Left = 1350
TabIndex = 1
Top = 1305
Width = 2415
End
Begin VB.Label Label2
Caption = "職工ID"
Height = 375
Left = 0
TabIndex = 10
Top = 120
Visible = 0 'False
Width = 855
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "職工姓名"
Height = 195
Left = 150
TabIndex = 8
Top = 630
Width = 720
End
Begin VB.Label lblField
AutoSize = -1 'True
Caption = "lblField"
Height = 195
Index = 4
Left = 150
TabIndex = 4
Top = 2745
Width = 480
End
Begin VB.Label lblField
AutoSize = -1 'True
Caption = "lblField"
Height = 195
Index = 3
Left = 150
TabIndex = 2
Top = 2070
Width = 480
End
Begin VB.Label lblField
AutoSize = -1 'True
Caption = "lblField"
Height = 195
Index = 2
Left = 150
TabIndex = 0
Top = 1395
Width = 480
End
End
Attribute VB_Name = "AddSForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'保證姓名與ID一致
Private Sub cmbName_Click()
cmbID.Text = cmbID.List(cmbName.ListIndex)
End Sub
'添加
Private Sub cmdAdd_Click()
'打開錯(cuò)誤處理陷阱
Dim intErrFileNo As Integer '自由文件號(hào)
On Error GoTo ErrGoto
'----------------------------------------------------
'生成SQL語句
SQL = "INSERT INTO 特殊項(xiàng)(職工ID,特殊項(xiàng)名稱,特殊項(xiàng)金額,特殊項(xiàng)日期) VALUES("""
SQL = SQL & cmbID.Text & ""","""
SQL = SQL & txtValue(2).Text & ""","
SQL = SQL & txtValue(3).Text & ",#"
SQL = SQL & txtValue(4).Text & "#)"
'打開數(shù)據(jù)連接
OpenDBFile
'執(zhí)行SQL
gCon.Execute SQL
'關(guān)閉數(shù)據(jù)連接
CloseDBFile
Me.Hide
'刷新數(shù)據(jù)
SpecialForm.Adodc1.Refresh
'----------------------------------------------------
Exit Sub
'-----------------------------
ErrGoto:
'把錯(cuò)誤信息保存在文件里
intErrFileNo = FreeFile()
Open "YFSystem.ini" For Append As intErrFileNo
Print #intErrFileNo, Chr(34) + Format(Now, "YYYY-MM-DD HH:MM:SS") + Chr(34), Chr(34) + "信息" + Chr(34), Chr(34) + Err.Description + Chr(34), Chr(34) + "Command1_Click(AddEForm)" + Chr(34), Chr(34) + App.Title + Chr(34)
MsgBox Err.Description
Close #intErrFileNo
Me.Hide
End Sub
'退出
Private Sub cmdCancel_Click()
Me.Hide
End Sub
'初始化
Private Sub Form_activate()
'打開錯(cuò)誤處理陷阱
Dim intErrFileNo As Integer '自由文件號(hào)
On Error GoTo ErrGoto
'----------------------------------------------------
lblField(2).Caption = "特殊項(xiàng)名稱"
lblField(3).Caption = "特殊項(xiàng)金額"
lblField(4).Caption = "特殊項(xiàng)日期"
For i = 2 To 4
txtValue(i) = ""
Next
cmbID.Clear
cmbName.Clear
'打開數(shù)據(jù)集
OpenRS "Select 職工ID,姓名 from 職工"
'添加到ComboBox中
While Not gRst.EOF
cmbID.AddItem gRst("職工ID")
cmbName.AddItem gRst("姓名")
gRst.MoveNext
Wend
'關(guān)閉數(shù)據(jù)集
CloseRS
'----------------------------------------------------
Exit Sub
'-----------------------------
ErrGoto:
'把錯(cuò)誤信息保存在文件里
intErrFileNo = FreeFile()
Open "YFSystem.ini" For Append As intErrFileNo
Print #intErrFileNo, Chr(34) + Format(Now, "YYYY-MM-DD HH:MM:SS") + Chr(34), Chr(34) + "信息" + Chr(34), Chr(34) + Err.Description + Chr(34), Chr(34) + "Form_Load(AddSForm)" + Chr(34), Chr(34) + App.Title + Chr(34)
Close #intErrFileNo
End Sub
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -