0
每次單擊我窗體上的重置按鈕。我收到以下錯誤信息:單擊VBA窗體上的重置按鈕會導致錯誤
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