每次我单击表单上的重置按钮时。我收到以下错误消息:
Run-Time error '380':
Could not set the Value property. Invalid property value.
我试图调试代码,错误似乎来自以下几行:
cbo_prefRoom1.Value = "No preference"
cbo_prefRoom2.Value = "No preference"
cbo_prefRoom3.Value = "No preference"
什么可能导致此错误?我检查了表格,并且特别正确地引用了组合框。
下面是整个函数的代码:
Private Sub btn_Reset_Click()
' Reset form
Dim ctl As msforms.Control
For Each ctl In Me.Controls
Select Case TypeName(ctl)
Case "TextBox"
ctl.Text = ""
Case "CheckBox", "OptionButton", "ToggleButton"
ctl.Value = False
Case "ComboBox", "ListBox"
ctl.ListIndex = -1
End Select
Next ctl
Me.cbo_deptCode = "CO - Computer Science"
' Set default value for checkbox
Me.chk_week1.Value = True
Me.chk_week2.Value = True
Me.chk_week3.Value = True
Me.chk_week4.Value = True
Me.chk_week5.Value = True
Me.chk_week6.Value = True
Me.chk_week7.Value = True
Me.chk_week8.Value = True
Me.chk_week9.Value = True
Me.chk_week10.Value = True
Me.chk_week11.Value = True
' Set default value for round
Me.cbo_rounds = "Priority"
' Set default value for semester
Me.cbo_semester = "1"
' Set default value for priority
priority_y.Value = 1
' Set default value for lectureStyle
lecturestyle_trad = 1
' Set default value from roomStructure
rs_Tiered = 1
' Set default value for fac1,fac2,fac3
cbo_fac1.Value = "No preference"
cbo_fac2.Value = "No preference"
cbo_fac3.Value = "No preference"
' Set default value for prefRoom1,prefRoom2,prefRoom3
cbo_prefRoom1.Value = "No preference"
cbo_prefRoom2.Value = "No preference"
cbo_prefRoom3.Value = "No preference"
End Sub