VB编程题——设计一个用于设置字体属性的程序 具体如下

设计一个用于设置字体属性的程序,界面功能如下图所示。(图片在http://hi.baidu.com/crazyna123/album/item/f381a22dd1591... 设计一个用于设置字体属性的程序,界面功能如下图所示。
(图片在http://hi.baidu.com/crazyna123/album/item/f381a22dd1591529359bf70d.html
打开窗体时,产生30个[100,2000]之间的随即整数,显示在列表
框List1中。打开窗体时“排序”按钮不可用。单击“筛选”按钮
筛选出列表框List1中所有素数添加到列表框List2中。要求使用
动态数组保存筛选出的素数,单击“筛选”按钮后,“筛选”按钮不可用,“排序”按钮可用。
我还有另外一道题也请大家帮帮啦
http://zhidao.baidu.com/question/78227477.html
展开
 我来答
ARTERIOSCLEROS
2008-12-07 · TA获得超过4183个赞
知道大有可为答主
回答量:1672
采纳率:0%
帮助的人:2417万
展开全部
把以下代码用记事本保存为后缀名为.frm的文件中,用VB打开。
==================================
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command3
Caption = "Command3"
Height = 375
Left = 1920
TabIndex = 4
Top = 1920
Width = 855
End
Begin VB.CommandButton Command2
Caption = "Command2"
Height = 375
Left = 1920
TabIndex = 3
Top = 1200
Width = 855
End
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 375
Left = 1920
TabIndex = 2
Top = 480
Width = 855
End
Begin VB.ListBox List2
Height = 2400
Left = 2880
TabIndex = 1
Top = 360
Width = 1815
End
Begin VB.ListBox List1
Height = 2400
Left = 120
TabIndex = 0
Top = 360
Width = 1695
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Function IsPrime(ByVal n As Long) As Boolean
Dim i As Long
For i = 2 To Int(n / 2)
If n Mod i = 0 Then IsPrime = False: Exit Function
Next
IsPrime = True
End Function

Private Sub Command2_Click()
Dim i As Integer
ReDim a(0) As Integer
For i = 0 To 29
If IsPrime(List1.List(i)) Then
a(UBound(a)) = List1.List(i)
List2.AddItem a(UBound(a))
ReDim Preserve a(UBound(a) + 1)
End If
Next
Command1.Enabled = True
Command2.Enabled = False
End Sub

Private Sub Command3_Click()
End
End Sub

Private Sub Form_Load()
Command1.Caption = "排序"
Command2.Caption = "筛选"
Command3.Caption = "退出"
Command1.Enabled = False
Randomize
Dim i As Integer
For i = 1 To 30
List1.AddItem Int(Rnd * 1900 + 100)
Next
End Sub
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式