两道vb编程题

[复制链接]
查看11 | 回复0 | 2009-12-2 11:31:55 | 显示全部楼层 |阅读模式
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
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行