1.放入两个ListBox控件 名字分别是List1,List2mList1的sorted属性为True代码:Private Sub Form_Load()List1.AddItem "计算机应用"List1.AddItem "软件工程"List1.AddItem "信息化技术"List1.AddItem "数据库"List1.AddItem "C++"List1.AddItem "软件重用"List1.AddItem "web设计"End SubPrivate Sub List1_Click()If List2.ListCount = 4 Then
MsgBox "只能选4门课", , ""
Exit SubEnd IfList2.AddItem List1.TextList1.RemoveItem List1.ListIndexEnd Sub 2.Private Sub Command1_Click()
Dim num As Long, temp As Boolean
num = Val(Text1.Text)
temp= True
For i = 2 To Sqr(num )
If numMod i = 0 Then
temp= False
Exit For
End If
Next
if temp =false then
MsgBox num & "不是一个素数"
else
MsgBox num & "是一个素数"
end ifEnd Sub