优化年级设置添加课程
这个得优化两处,第一处点击设置课程就会加载一次,点击一次就会出现一次。
我想的办法是点击一次,就让设置课程按钮失效
cmdSet.Enabled = False 这样就行了
第二处 是 添加已经选择课程,能重复添加课程。
优化的时候
Private Sub cmdAdd_Click()
Static b As Integer
Dim a As Integer
If listAllcourse.ListIndex <> -1 Then
For b = 0 To listSelectcourse.ListCount - 1
If listSelectcourse.List(b) = listAllcourse.List(listAllcourse.ListIndex) Then
MsgBox "不能重复添加课程"
a = 3
End If
Next
If a = 3 Then
Exit Sub
Else
listSelectcourse.AddItem listAllcourse.List(listAllcourse.ListIndex)
End If
End If
End Sub