📄 form1.frm
字号:
Caption = "平均成绩"
End
Begin VB.Menu sclass
Caption = "所属班级"
End
Begin VB.Menu acg
Caption = "所有成绩"
End
Begin VB.Menu addcg
Caption = "输入成绩"
End
Begin VB.Menu cg02
Caption = "-"
End
Begin VB.Menu returncg
Caption = "返回"
End
End
Begin VB.Menu student
Caption = "学生信息"
Visible = 0 'False
Begin VB.Menu addstudent
Caption = "新增学生"
End
Begin VB.Menu findcg
Caption = "查询成绩"
End
Begin VB.Menu savestudent
Caption = "保存"
End
Begin VB.Menu student01
Caption = "-"
End
Begin VB.Menu editstudent
Caption = "提交修改"
End
Begin VB.Menu delstudent
Caption = "删除对象"
End
Begin VB.Menu student02
Caption = "-"
End
Begin VB.Menu renovate
Caption = "刷新"
End
End
End
Attribute VB_Name = "form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim i, j, n As Integer
Dim sql As String
Private Declare Function GetKeyState Lib "user32" _
(ByVal nVirtKey As Long) As Integer
Public je As Integer '记忆菜单上次数值,实现数据传送
Private Sub acg_Click()
Call asPopup7_Click(False)
End Sub
Private Sub addcg_Click()
Call asPopup6_Click(False)
End Sub
Private Sub addstudent_Click()
Call asPopup2_Click(False)
End Sub
Private Sub asPopup1_Click(Cancel As Boolean)
Grid1.Visible = True
Grid2.Visible = False
tkbase = "学生信息"
fnumber = 13
sql = "select * from " & tkbase & " order by 学号 desc"
grid1pz '执行grid1的分配空间任务
datagrid '按要求读取数据空间
End Sub
Private Sub grid1pz() '处理grid1的操作
Grid1.Cols = fnumber + 1
Grid1.Column(1).Width = 120
Grid1.Column(2).Width = 100
Grid1.Column(3).Width = 80
Grid1.Column(4).Width = 40
Grid1.Column(5).Width = 80
Grid1.Column(6).Width = 30
Grid1.Column(7).Width = 50
Grid1.Column(8).Width = 80
Grid1.Column(9).Width = 60
Grid1.Column(10).Width = 80
Grid1.Column(11).Width = 100
Grid1.Column(12).Width = 100
Grid1.Column(13).Width = 100
Grid1.Column(4).CellType = cellComboBox
Grid1.ComboBox(4).Clear
Grid1.ComboBox(4).AddItem "男"
Grid1.ComboBox(4).AddItem "女"
Grid1.Column(5).CellType = cellCalendar
Grid1.Column(2).CellType = cellComboBox
Grid1.ComboBox(2).Clear
Set qy2 = cnn.Execute("select 班级名称 from 班级")
Do While Not qy2.EOF
Grid1.ComboBox(2).AddItem qy2.Fields(0)
qy2.MoveNext
Loop
Grid1.Column(9).CellType = cellComboBox
Grid1.ComboBox(9).Clear
Grid1.ComboBox(9).AddItem "团员"
Grid1.ComboBox(9).AddItem "党员"
Grid1.ComboBox(9).AddItem "无"
Grid1.Column(1).Locked = True
End Sub
Private Sub asPopup10_Click(Cancel As Boolean)
Dim fo2 As CTranslucentForm
Set fo2 = New CTranslucentForm
fo2.hWnd = Form6.hWnd
fo2.Alpha = 90 / 100 * 255
Me.WindowState = vbMinimized
Load Form6
Form6.Show 1
End Sub
Private Sub asPopup2_Click(Cancel As Boolean)
Grid1.Visible = True
Grid2.Visible = False
tkbase = "学生信息"
fnumber = 13
Set qy1 = cnn.Execute("select * from " & tkbase)
grid1pz
For i = 1 To fnumber
Grid1.Cell(0, i).Text = qy1.Fields(i - 1).Name
Next
Grid1.Column(1).Locked = False
Grid1.Rows = 1
Grid1.Rows = 21
gridsave = True '允许保存
griddelete = False '拒绝删除
gridedit = False
End Sub
Private Sub asPopup3_Click(Cancel As Boolean)
Dim fo2 As CTranslucentForm
Set fo2 = New CTranslucentForm
fo2.hWnd = Form2.hWnd
fo2.Alpha = 90 / 100 * 255
Me.WindowState = vbMinimized
Load Form2
Form2.Show 1
End Sub
Private Sub asPopup4_Click(Cancel As Boolean)
Dim fo2 As CTranslucentForm
Set fo2 = New CTranslucentForm
fo2.hWnd = Form4.hWnd
fo2.Alpha = 90 / 100 * 255
Me.WindowState = vbMinimized
Load Form4
Form4.Show 1
End Sub
Private Sub asPopup5_Click(Cancel As Boolean)
Frame2.Visible = True
End Sub
Private Sub asPopup6_Click(Cancel As Boolean)
Grid1.Visible = False
Grid2.Visible = True
tkbase = "学生与课程"
fnumber = 6
gridpz2
Set qy1 = cnn.Execute("select * from " & tkbase)
For i = 1 To fnumber
Grid2.Cell(0, i).Text = qy1.Fields(i - 1).Name
Next
Grid2.Rows = 1
Grid2.Rows = 21
gridsave = True
gridedit = False
griddel = False
Grid2.Column(1).Locked = False
Grid2.Column(2).Locked = True
Grid2.Column(3).Locked = False
Grid2.Column(4).Locked = True
End Sub
Private Sub asPopup7_Click(Cancel As Boolean)
Grid1.Visible = False
Grid2.Visible = True
tkbase = "学生与课程"
fnumber = 6
sql = "select * from " & tkbase & " order by 学号 asc"
gridpz2
datagrid
gridsave = False
gridedit = True
griddel = True
Grid2.Column(1).Locked = True
Grid2.Column(2).Locked = True
Grid2.Column(3).Locked = True
Grid2.Column(4).Locked = True
End Sub
Private Sub gridpz2()
Grid2.Cols = 8
Grid2.Column(1).Width = 120
Grid2.Column(3).Width = 120
Grid2.Column(1).CellType = cellComboBox
Set qy1 = cnn.Execute("select * from 课程")
Grid2.ComboBox(1).Clear
Do While Not qy1.EOF
Grid2.ComboBox(1).AddItem qy1.Fields(0) & "-" & qy1.Fields(1)
qy1.MoveNext
Loop
Grid2.Column(3).CellType = cellComboBox
Set qy1 = cnn.Execute("select 学号,名字 from 学生信息")
Grid2.ComboBox(3).Clear
Do While Not qy1.EOF
Grid2.ComboBox(3).AddItem qy1.Fields(0) & "-" & qy1.Fields(1)
qy1.MoveNext
Loop
End Sub
Private Sub asPopup8_Click(Cancel As Boolean)
Dim fo2 As CTranslucentForm
Set fo2 = New CTranslucentForm
fo2.hWnd = Form7.hWnd
fo2.Alpha = 85 / 100 * 255
Load Form7
Form7.Show 1
End Sub
Private Sub asPopup9_Click(Cancel As Boolean)
End
End Sub
Private Sub c1_Click(Index As Integer) '提交内容到函数执行,4为当前菜单(0-4),index是按钮数组名称
cmove 4, Index
End Sub
Private Sub cmove(s As Integer, i As Integer) '菜单智能移动函数代码S代表菜单的总数,i代表当前移动的是数组名称
Dim j As Integer
Dim x, y, z, x1, y1 As Integer
x = s '将x,y,z,x1赋于菜单总数,x存放frame1的固定值
y = s 'y存放的是移动后的按钮的固定值
z = s 'Z没用上
x1 = s 'X1没用上
j = 0 'j计算按钮的宽度
Do While s > 0 ' 这里是通过重复计算来计算按钮所需移动的总高度
If je > i Then
Do While x > i
Do While y >= x
j = j + 360 '360是每个按钮的高度
y = y - 1
Loop
c1(x).Top = Fre1.Height - j
x = x - 1
Loop
Else
'-----------------向上代码
For x = 0 To i
For y = 0 To x
j = j + 360
Next
c1(x).Top = j - 360
j = 0
Next
End If
s = s - 1
For y1 = 0 To x1
If y1 = i Then
Fre2(y1).Visible = True
Fre2(y1).Top = c1(y1).Top + c1(y1).Height
If y1 <> z Then
Fre2(y1).Height = c1(y1 + 1).Top - Fre2(y1).Top
Else
Fre2(y1).Height = Fre1.Height - c1(y1).Top - c1(y1).Height
End If
Else
Fre2(y1).Visible = False
End If
Next
Loop
je = i '这里是记忆上次移动的按钮数组编号
End Sub
Private Sub cgdel_Click()
Call XPButton6_Click
End Sub
Private Sub cgedit_Click()
Call XPButton4_Click
End Sub
Private Sub delstudent_Click()
Call XPButton6_Click
End Sub
Private Sub editstudent_Click()
Call XPButton4_Click
End Sub
Private Sub findcg_Click()
If hang = 0 Then
Exit Sub
End If
Grid1.Visible = False
Grid2.Visible = True
tkbase = "学生与课程"
fnumber = 5
sql = "select * from 学生与课程 where 学号='" & Grid1.Cell(hang, 1).Text & "'"
gridpz2
datagrid
gridsave = False
gridedit = True
griddel = True
Grid2.Column(1).Locked = True
Grid2.Column(2).Locked = True
Grid2.Column(3).Locked = True
End Sub
Private Sub Grid1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 2 Then
If gridsave = True Then
savestudent.Enabled = True
Else
savestudent.Enabled = False
End If
If gridedit = True Then
editstudent.Enabled = True
Else
editstudent.Enabled = False
End If
If griddel = True Then
delstudent.Enabled = True
Else
delstudent.Enabled = False
End If
If admin = False Then
addstudent.Enabled = False
savestudent.Enabled = False
editstudent.Enabled = False
delstudent.Enabled = False
End If
PopupMenu student
End If
End Sub
Private Sub Grid1_RowColChange(ByVal Row As Long, ByVal Col As Long)
hang = Row
If gridsave = True And Col = 5 Then '确认默认年龄在20岁左右
If Row <> 0 Then
Grid1.Cell(Row, 5).Text = Date - 7300
End If
End If
End Sub
Private Sub Grid1_Validate(Cancel As Boolean) '设定TAB键切换
Dim nActiveRow As Long, nActiveCol As Long
Const VK_TAB = 9
If GetKeyState(VK_TAB) < 0 Then
nActiveRow = Grid1.ActiveCell.Row
nActiveCol = Grid1.ActiveCell.Col
If nActiveCol < Grid1.Cols - 1 Then
Grid1.Range(nActiveRow, nActiveCol + 1, _
nActiveRow, nActiveCol + 1).Selected
End If
Cancel = True
End If
End Sub
Private Sub Form_Load()
On Error GoTo finish
Grid1.SetRegisterInformation "CNwinndy", "W]vyY-nonvk-u\nty-Zbl_e-`hms^" '进行注册
Grid2.SetRegisterInformation "CNwinndy", "W]vyY-nonvk-u\nty-Zbl_e-`hms^" '进行注册
Label2.Caption = "今天是" & Year(Date) & "年" & Month(Date) & "月" & Day(Date) & "日,欢迎您进入!"
Frame2.Visible = False
form1.BackColor = RGB(167, 111, 177)
'-------------管理员验证
If admin = False Then
c1(3).Enabled = False
asPopup2.Enabled = False '增加学生
asPopup4.Enabled = False '课程管理
asPopup6.Enabled = False '输入成绩
XPButton4.Enabled = False
XPButton5.Enabled = False
XPButton6.Enabled = False
End If
With Grid1
.AllowUserResizing = True
.DisplayFocusRect = False
.ExtendLastCol = True
.Appearance = Flat
.FixedRowColStyle = Flat
.ScrollBarStyle = Flat
.DefaultFont.Name = "Tahoma"
.DefaultFont.SIZE = 8
.BackColorFixed = RGB(84, 201, 134)
.BackColorFixedSel = RGB(167, 111, 177)
.BackColorBkg = RGB(198, 229, 211)
.BackColorScrollBar = RGB(167, 111, 177)
.BackColor1 = RGB(231, 235, 247)
.BackColor2 = RGB(198, 229, 211)
.GridColor = RGB(148, 190, 231)
.Column(0).Width = 0
End With
With Grid2
.AllowUserResizing = True
.DisplayFocusRect = False
.ExtendLastCol = True
.Appearance = Flat
.FixedRowColStyle = Flat
.ScrollBarStyle = Flat
.AllowUserResizing = True
.DisplayFocusRect = False
.ExtendLastCol = True
.Appearance = Flat
.FixedRowColStyle = Flat
.ScrollBarStyle = Flat
.DefaultFont.Name = "Tahoma"
.DefaultFont.SIZE = 8
.BackColorFixed = RGB(84, 201, 134)
.BackColorFixedSel = RGB(167, 111, 177)
.BackColorBkg = RGB(198, 229, 211)
.BackColorScrollBar = RGB(167, 111, 177)
.BackColor1 = RGB(231, 235, 247)
.BackColor2 = RGB(198, 229, 211)
.GridColor = RGB(148, 190, 231)
.Column(0).Width = 0
End With
je = 4
Dim fr As Integer
Fre1.BackColor = RGB(168, 217, 189)
For fr = 0 To 4
Fre2(fr).Visible = False
Fre2(fr).BackColor = RGB(106, 137, 188)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -