?? frmmodicourse.frm
字號:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form frmModiCourse
BorderStyle = 1 'Fixed Single
Caption = "修改課程"
ClientHeight = 2265
ClientLeft = 2460
ClientTop = 2430
ClientWidth = 5175
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2265
ScaleWidth = 5175
Begin MSAdodcLib.Adodc adoEdit
Align = 2 'Align Bottom
Height = 375
Left = 0
Top = 1890
Width = 5175
_ExtentX = 9128
_ExtentY = 661
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 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Stud97.mdb;Persist Security Info=False"
OLEDBString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Stud97.mdb;Persist Security Info=False"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "SELECT * FROM 課程信息 ORDER BY 課號"
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋體"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.Frame Frame1
Caption = "修改課程"
Height = 1215
Left = 600
TabIndex = 5
Top = 120
Width = 3975
Begin VB.TextBox txtCourseNo
DataField = "課號"
DataSource = "adoEdit"
Height = 264
Left = 1320
TabIndex = 7
Top = 360
Width = 2055
End
Begin VB.TextBox txtCourseName
DataField = "課程"
DataSource = "adoEdit"
Height = 264
Left = 1320
TabIndex = 6
Top = 720
Width = 2055
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "課程編號"
Height = 180
Left = 480
TabIndex = 9
Top = 405
Width = 720
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "課程名稱"
Height = 180
Left = 480
TabIndex = 8
Top = 765
Width = 720
End
End
Begin VB.CommandButton cmdEdit
Caption = "修改記錄"
Height = 312
Left = 60
TabIndex = 4
Top = 1610
Width = 972
End
Begin VB.CommandButton cmdUpdate
Caption = "更新數據"
Height = 312
Left = 1080
TabIndex = 3
Top = 1610
Width = 972
End
Begin VB.CommandButton cmdCancel
Caption = "取消修改"
Height = 312
Left = 2100
TabIndex = 2
Top = 1610
Width = 972
End
Begin VB.CommandButton cmdDelect
Caption = "刪除記錄"
Height = 312
Left = 3120
TabIndex = 1
Top = 1610
Width = 972
End
Begin VB.CommandButton cmdExit
Caption = "退出"
Height = 312
Left = 4140
TabIndex = 0
Top = 1610
Width = 972
End
End
Attribute VB_Name = "frmModiCourse"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'修改課程窗體frmModiCourse
Option Explicit
Private Sub adoEdit_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, _
ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, _
ByVal pRecordset As ADODB.Recordset)
'顯示當前記錄位置/總記錄數
adoEdit.Caption = "Record: " & _
CStr(adoEdit.Recordset.AbsolutePosition) & _
"/" & adoEdit.Recordset.RecordCount
End Sub
Private Sub cmdCancel_Click() '取消
With adoEdit.Recordset
.CancelUpdate '取消更新
.MoveNext
.MovePrevious
End With
Call MyLock(True)
End Sub
Private Sub cmdDelect_Click() '刪除
Dim Response As Integer
Response = MsgBox("刪除當前記錄嗎?", vbQuestion + vbYesNo, "詢問")
If Response = vbYes Then
With adoEdit.Recordset
.Delete
.MoveNext
If .EOF Then .MoveLast
End With
End If
End Sub
Private Sub cmdEdit_Click() '修改
Call MyLock(False)
End Sub
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub cmdUpdate_Click() '更新
On Error Resume Next
'各文本框若為空白,提示重新輸入
If Trim$(txtCourseNo.Text) = "" Then
MsgBox "請輸入課程編號!", vbExclamation
txtCourseNo.SetFocus
Exit Sub
End If
If Trim$(txtCourseName.Text) = "" Then
MsgBox "請輸入課程名稱!", vbExclamation
txtCourseName.SetFocus
Exit Sub
End If
adoEdit.Recordset.Update '更新數據庫
If Err = -2147467259 Then '該錯誤號為主鍵重復錯誤
MsgBox "課程編號重復,請重新輸入!", vbExclamation
With txtCourseNo '焦點返回課號框
.SelStart = 0
.SelLength = Len(.Text)
.SetFocus
End With
Exit Sub
End If
MsgBox "課程信息已成功修改!", vbInformation
Call MyLock(True) '鎖定
End Sub
Private Sub Form_Initialize()
ChDrive App.Path
ChDir App.Path
End Sub
Private Sub Form_Load()
Call MyLock(True)
End Sub
Private Sub Form_Unload(Cancel As Integer) '窗體卸載時
frmMain.Show
End Sub
Private Sub MyLock(ByVal bLock As Boolean) '自定義過程:鎖定/解鎖用于輸入的控件
txtCourseNo.Locked = bLock 'True
txtCourseName.Locked = bLock 'True
cmdEdit.Enabled = bLock 'True
cmdCancel.Enabled = Not bLock 'False
cmdUpdate.Enabled = Not bLock 'False
adoEdit.Enabled = bLock 'True
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -