📄 frmmodigrade.frm
字号:
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ColumnCount = 2
BeginProperty Column00
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column01
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
SplitCount = 1
BeginProperty Split0
BeginProperty Column00
ColumnWidth = 1005.165
EndProperty
BeginProperty Column01
ColumnWidth = 1019.906
EndProperty
EndProperty
End
End
Begin MSAdodcLib.Adodc adononame
Height = 375
Left = 4185
Top = 5040
Visible = 0 'False
Width = 2025
_ExtentX = 3572
_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=student.mdb;Persist Security Info=False"
OLEDBString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=student.mdb;Persist Security Info=False"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = ""
Caption = "Adodc2"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin MSAdodcLib.Adodc adoedit
Height = 375
Left = 285
Top = 5040
Visible = 0 'False
Width = 3900
_ExtentX = 6879
_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=student.mdb;Persist Security Info=False"
OLEDBString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=student.mdb;Persist Security Info=False"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = ""
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 = "选择班级"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00404040&
Height = 1095
Left = 240
TabIndex = 0
Top = 120
Width = 2910
Begin VB.ComboBox cboclass
Height = 300
ItemData = "frmmodigrade.frx":0000
Left = 240
List = "frmmodigrade.frx":0002
TabIndex = 1
Top = 480
Width = 2355
End
End
End
Attribute VB_Name = "frmmodigrade"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim strgrade As String
Option Explicit
Private Sub adononame_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
If adononame.Recordset.BOF Or adononame.Recordset.EOF Then
txtno.Text = ""
txtname.Text = ""
txtgrade.Text = ""
Exit Sub
End If
txtno.Text = adononame.Recordset("学号").Value
txtname.Text = adononame.Recordset("姓名").Value
Dim sql As String
sql = "select * from 成绩 where 学号='" & txtno.Text & "'"
adoedit.RecordSource = sql
adoedit.Refresh
cbocourse.Clear
With adoedit.Recordset
Do Until .EOF
cbocourse.AddItem .Fields("课程").Value
.MoveNext
Loop
End With
If cbocourse.ListCount > 0 Then
cbocourse.ListIndex = 0
Else
txtgrade.Text = ""
End If
End Sub
Private Sub cboclass_Click()
Dim sqln As String
sqln = "select distinct 成绩.学号 as 学号,学籍.姓名 as 姓名 from 成绩,学籍 where 学籍.学号=成绩.学号 and 班级='" & cboclass.Text & "' order by 成绩.学号"
adononame.RecordSource = sqln
adononame.Refresh
With dgdnoname
Set .DataSource = adononame
.Columns(0).Width = 1100
.Columns(1).Width = 1100
End With
End Sub
Private Sub cbocourse_Click()
If Trim$(txtno.Text) = "" Or Trim$(cbocourse.Text) = "" Then
txtgrade.Text = ""
Exit Sub
Else
With adoedit.Recordset
If .RecordCount > 0 Then .MoveFirst
.Find "课程='" & cbocourse.Text & "'"
If .EOF Then Exit Sub
txtgrade.Text = .Fields("分数").Value
End With
End If
End Sub
Private Sub cmdcancel_Click()
txtgrade.Text = strgrade
Call mylock(True)
End Sub
Private Sub cmddelete_Click()
If Trim$(txtno.Text) = "" Or Trim$(cbocourse.Text) = "" Then Exit Sub
Dim response As Integer
response = MsgBox("删除当前记录吗?", vbQuestion + vbYesNo, "询问")
If response = vbYes Then
With adoedit.Recordset
.Delete
.Update
Dim sngwait As Single
sngwait = Timer
Do Until Timer - sngwait > 1#
'frawait.Visible = True
DoEvents
Loop
'frawait.Visible = False
If .RecordCount = 0 Then
MsgBox "成绩表中已无该学生的成绩", vbInformation, "提示"
Else
MsgBox "成绩删除成功。", vbInformation, "提示"
End If
adononame.Refresh
'dgdnoname.Columns(0).Width = 1100
'dgdnoname.Columns(1).Width = 1100
End With
End If
Call mylock(True)
End Sub
Private Sub cmdedit_Click()
If Trim$(txtno.Text) = "" Or Trim$(cbocourse.Text) = "" Then Exit Sub
strgrade = txtgrade.Text
Call mylock(False)
Call focusback(txtgrade)
End Sub
Private Sub cmdexit_Click()
Unload Me
End Sub
Private Sub cmdupdate_Click()
If Trim$(txtgrade.Text) = "" Then
MsgBox "请输入成绩!若无成绩,请将该记录删除", vbExclamation, "提示"
Call cmdcancel_Click
txtgrade.SetFocus
Exit Sub
End If
With adoedit.Recordset
.Fields("分数").Value = Val(txtgrade.Text)
.Update
End With
MsgBox "成绩修改成功。", vbInformation
Call mylock(True)
End Sub
Private Sub Form_Load()
Call mylock(True)
Call addclassitem(cboclass)
'frawait.Top = 1200
'frawait.Left = 1600
dgdnoname.AllowUpdate = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
frmMain.Show
End Sub
Private Sub mylock(ByVal block As Boolean)
txtgrade.Locked = block
cboclass.Locked = Not block
cbocourse.Locked = Not block
cmdedit.Enabled = block
cmdcancel.Enabled = Not block
cmdupdate.Enabled = Not block
dgdnoname.Enabled = block
End Sub
Private Sub txtgrade_KeyPress(KeyAscii As Integer)
If Not IsNumeric(Chr(KeyAscii)) And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -