📄 frmmarks.frm
字号:
Caption = "Address:"
Height = 180
Index = 2
Left = 240
TabIndex = 8
Top = 720
Width = 720
End
Begin VB.Label Label1
Alignment = 2 'Center
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "Batch:"
Height = 180
Index = 3
Left = 360
TabIndex = 7
Top = 1080
Width = 540
End
Begin VB.Label Label1
Alignment = 2 'Center
AutoSize = -1 'True
Caption = "Facuity:"
Height = 180
Index = 4
Left = 3600
TabIndex = 6
Top = 1080
Width = 720
End
End
Begin VB.Label Label2
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "Exam Date:"
Height = 180
Index = 1
Left = 3720
TabIndex = 13
Top = 2040
Width = 900
End
Begin VB.Label Label2
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "Semester:"
Height = 180
Index = 0
Left = 720
TabIndex = 11
Top = 2040
Width = 810
End
End
Attribute VB_Name = "frmMarks"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim Cnt As ADODB.Recordset
Dim Ct As String
Dim Acc As Boolean
' Dim Cnt1 As ADODB.Recordset
' Dim Ct1 As String
Private Sub cmdEdit_Click()
TextEnable1
TextK1
cmdNew.Enabled = False
cmdEdit.Enabled = False
cmdSave.Enabled = True
Acc = False
End Sub
Private Sub cmdNew_Click()
TextEnable1
TextK
cmdNew.Enabled = False
cmdEdit.Enabled = False
cmdSave.Enabled = True
Acc = True
End Sub
Private Sub cmdSave_Click()
If Acc = True Then
FillRecord
Else
FillRecord1
End If
cmdNew.Enabled = True
cmdEdit.Enabled = True
cmdSave.Enabled = False
TextEnable
End Sub
Private Sub Form_Load()
Set Cnt = New Recordset
Ct = "select * from Exam"
Cnt.Open Ct, Str, adOpenKeyset, adLockOptimistic, adCmdText
FillText
TextEnable
TextEnable3
frmMarks.Width = 6930
frmMarks.Height = 6885
Acc = False
' Set Cnt1 = New Recordset
' Ct1 = "select * from Admission "
' Cnt1.Open Ct1, Str, adOpenKeyset, adLockOptimistic, adCmdText
' Call Marks(Ct1)
End Sub
Private Sub cmdExit_Click()
If MsgBox("确实要退出吗?", vbOKCancel + vbQuestion, "窗体退出") = vbOK Then
Unload Me
Else
Exit Sub
End If
End Sub
Private Sub cmdFrist_Click()
If Cnt.RecordCount = 0 Then Exit Sub
Cnt.MoveFirst
FillText
End Sub
Private Sub cmdLast_Click()
If Cnt.RecordCount = 0 Then Exit Sub
Cnt.MoveLast
FillText
End Sub
Private Sub cmdNext_Click()
If Cnt.RecordCount = 0 Then Exit Sub
Cnt.MoveNext
If Cnt.EOF = True Then
MsgBox "纪录已是尾记录", vbOKOnly + vbExclamation, "浏览记录"
Cnt.MoveLast
FillText
End If
FillText
End Sub
Private Sub cmdPrevious_Click()
If Cnt.RecordCount = 0 Then Exit Sub
Cnt.MovePrevious
If Cnt.BOF = True Then
MsgBox "纪录已是首记录", vbOKOnly + vbExclamation, "浏览记录"
Cnt.MoveFirst
FillText
End If
FillText
End Sub
Private Sub TextEnable()
Dim i As Integer
For i = 0 To 7
txtRecord1(i).Enabled = False
Next
End Sub
Private Sub TextEnable1()
Dim i As Integer
For i = 0 To 7
txtRecord1(i).Enabled = True
Next
End Sub
Private Sub TextEnable3()
Dim i As Integer
For i = 0 To 3
txtFillRecord1(i).Enabled = False
Next
End Sub
Private Sub FillText()
Dim i As Integer
If Cnt.RecordCount <= 0 Then Exit Sub
txtRecord1(0).Text = Cnt(1)
txtRecord1(1).Text = Cnt(2)
txtRecord1(2).Text = Cnt(3)
txtRecord1(3).Text = Cnt(4)
txtRecord1(4).Text = Cnt(5)
txtRecord1(5).Text = Cnt(6)
txtRecord1(6).Text = Cnt(7)
txtRecord1(7).Text = Cnt(8)
End Sub
Private Sub TextK()
Dim i As Integer
If Cnt.RecordCount = 0 Then Exit Sub
For i = 0 To 7
txtRecord1(i) = ""
txtRecord1(0).SetFocus
Next
End Sub
Private Sub TextK1()
If Cnt.RecordCount = 0 Then Exit Sub
txtRecord1(0).SetFocus
End Sub
Private Sub FillRecord()
Dim i As Integer
Cnt.AddNew
Cnt(1) = txtRecord1(0).Text
Cnt(2) = txtRecord1(1).Text
Cnt(3) = txtRecord1(2).Text
Cnt(4) = txtRecord1(3).Text
Cnt(5) = txtRecord1(4).Text
Cnt(6) = txtRecord1(5).Text
Cnt(7) = txtRecord1(6).Text
Cnt(8) = txtRecord1(7).Text
Cnt.Update
Cnt.MoveFirst
FillText
End Sub
Private Sub FillRecord1()
Dim i As Integer
Cnt(1) = txtRecord1(0).Text
Cnt(2) = txtRecord1(1).Text
Cnt(3) = txtRecord1(2).Text
Cnt(4) = txtRecord1(3).Text
Cnt(5) = txtRecord1(4).Text
Cnt(6) = txtRecord1(5).Text
Cnt(7) = txtRecord1(6).Text
Cnt(8) = txtRecord1(7).Text
Cnt.Update
Cnt.MoveFirst
FillText
End Sub
'Private Sub Marks(Cr As String)
' Ct1 = "select Sid from Admission where sid='" & Cr & "'"
'
' If Trim(Cnt1("sid")) = Trim(txtFillRecord.Text) Then
' txtFillRecord1(0).Text = Cnt1("Name")
' txtFillRecord1(1).Text = Cnt1("Address")
' txtFillRecord1(2).Text = Cnt1("Batch")
' txtFillRecord1(3).Text = Cnt1("Faculty")
' Else
' txtFillRecord1(0).Text = ""
' txtFillRecord1(1).Text = ""
' txtFillRecord1(2).Text = ""
' txtFillRecord1(3).Text = ""
' End If
'End Sub
Private Sub txtFillRecord_Change()
'' Dim Sa As String
'' Sa = txtFillRecord.Text
'' Call Marks(Sa)
Dim findStr As String
' Dim cnn2 As New ADODB.Connection
Dim rsSearch As New ADODB.Recordset
' If Text1(0).Text = Empty Then
' MsgBox "Cannot be Left Empty"
' txtFind.SetFocus
' Exit Sub
' End If
Set rsSearch = New Recordset
findStr = "select * from Admission where sid='" & txtFillRecord.Text & "'"
' cnn2.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\SAdmin.mdb;Persist Security Info=False"
' cnn2.Open
rsSearch.Open findStr, Str, adOpenDynamic
If rsSearch.EOF And rsSearch.BOF Then
txtFillRecord1(0).Text = ""
txtFillRecord1(1).Text = ""
txtFillRecord1(2).Text = ""
txtFillRecord1(3).Text = ""
Else
txtFillRecord1(0).Text = rsSearch(1)
txtFillRecord1(1).Text = rsSearch(2)
txtFillRecord1(2).Text = rsSearch(3)
txtFillRecord1(3).Text = rsSearch(4)
' txtFillRecord1(4).Text = rsSearch(4)
' txtFillRecord1(5).Text = rsSearch(5)
End If
' Dim Find As ADODB.Recordset
' Dim Find1 As String
' Set Find = New Recordset
'
' Find1 = "select * from admission where sid='" & txtFillRecord.Text & "'"
' Find.Open Find1, Str, adOpenKeyset, adLockOptimistic, adCmdText
' If Find.EOF And Find.BOF Then
' txtFillRecord1(0).Text = ""
' txtFillRecord1(1).Text = ""
' txtFillRecord1(2).Text = ""
' txtFillRecord1(3).Text = ""
' Else
' txtFillRecord1(0).Text = Find(1)
' txtFillRecord1(1).Text = Find(2)
' txtFillRecord1(2).Text = Find(3)
' txtFillRecord1(3).Text = Find(4)
' End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -