成绩录入界面html代码,快速查找到学生并录入成绩的代码

这段VBA代码主要用于处理Excel工作表中的数据。它创建了一个Scripting.Dictionary对象,遍历特定格式的工作表,填充下拉列表,并进行数据验证及单元格赋值。当用户在下拉列表中选择特定项时,程序会更新指定单元格的值。
摘要由CSDN通过智能技术生成

Public d As Object

Private Sub cmd_exit_Click()

Unload UserForm1

End Sub

Private Sub cmd_ok_Click()

With Me

If .ComboBox1.ListIndex <> -1 And .ComboBox2.ListIndex <> -1 And .ComboBox3.ListIndex <> -1 And .ComboBox4.ListIndex <> -1 And .TextBox5.Text <> "" And .TextBox6.Text <> "" Then

nj = .ComboBox1.Text

bj = .ComboBox2.Text

xh = Val(.ComboBox4.Text)

If d.exists(nj) Then

If d(nj).exists(bj) Then

If d(nj)(bj).exists(xh) Then

brr = d(nj)(bj)(xh)

n = .ComboBox3.ListIndex + 4

m = brr(1) + 3

With Worksheets(nj)

.Cells(m, n) = Val(Me.TextBox6.Text)

End With

End If

End If

End If

End If

End With

End Sub

Private Sub ComboBox1_Change()

With Me

nj = .ComboBox1.Text

With .ComboBox2

.List = d(nj).keys

End With

End With

End Sub

Private Sub ComboBox2_Change()

With Me

nj = .ComboBox1.Text

bj = .ComboBox2.Text

With .ComboBox4

.List = d(nj)(bj).keys

End With

End With

End Sub

Private Sub ComboBox4_Change()

With Me

nj = .ComboBox1.Text

bj = .ComboBox2.Text

xh = Val(.ComboBox4.Text)

brr = d(nj)(bj)(xh)

.TextBox5.Value = brr(0)

End With

End Sub

Private Sub Label3_Click()

End Sub

Private Sub UserForm_Initialize()

Dim r%, i%

Dim arr, brr

Dim ws As Worksheet

Set d = CreateObject("scripting.dictionary")

For Each ws In Worksheets

If ws.Name Like "*年级" Then

Set d(ws.Name) = CreateObject("scripting.dictionary")

With ws

r = .Cells(.Rows.Count, 1).End(xlUp).Row

arr = .Range("a4:c" & r)

For i = 1 To UBound(arr)

If Not d(ws.Name).exists(arr(i, 2)) Then

Set d(ws.Name)(arr(i, 2)) = CreateObject("scripting.dictionary")

End If

d(ws.Name)(arr(i, 2))(arr(i, 1)) = Array(arr(i, 3), i)

Next

End With

End If

Next

With Me

With .ComboBox1

.List = d.keys

End With

With .ComboBox3

.List = Array("语文", "数学", "英语")

.ListIndex = 0

End With

End With

End Sub

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值