急!VB实训题目!!不会做!求高手帮忙
程序运行时在文本框1(text1)中生成20个[1,30]之间的随机整数。
在一个frame框里面有三个单选按钮:option1为1-10,option2为11-20,options3为21-30
文本框2(text2)为输出结果
有一个按钮为“统计”,单击“统计”按钮,将统计结果显示文本框2(text2)
补充一下:例如 当你选择 option1:1-10时 在text1中的随机数中检测符合条件的数值 然后统计符合条件数值的个数 这时文本框2的内容为:1-10的个数为: 展开
Private Sub Command1_Click()
Dim n As Integer
n = 1
S = Split(Text1.Text, ",")
For b = 0 To 29
If Option1(0).Value = True Then
If (S(b) > 0) And (S(b) <= 10) Then
m = 0
Text2.Text = Text2.Text + S(b) + " "
n = n + 1
End If
End If
If Option1(1).Value = True Then
If (S(b) > 10) And (S(b) <= 20) Then
m = 1
Text2.Text = Text2.Text + S(b) + " "
n = n + 1
End If
End If
If Option1(2).Value = True Then
If (S(b) > 20) And (S(b) <= 30) Then
m = 2
Text2.Text = Text2.Text + S(b) + " "
n = n + 1
End If
End If
Next b
Text2.Text = Text2.Text + S(b) + "," + Option1(m).Caption + "的个数是 " & n - 1 & "个"
End Sub
Private Sub Form_Load()
Randomize
For i = 1 To 30
Text1.Text = Text1.Text & Int(30 * Rnd + 1) & ","
Next i
End Sub
Private Sub Option1_Click(Index As Integer)
Text2.Text = ""
End Sub
private sub 统计()
if option1 then
i=0
elseif option2 then
i=10
else
i=20
endif
数据=split(text1,",")
n=0
for j=0 to 19
if val(数据(j))>i and val(数据(j))<i+11 then n=n+1
next i
text2=i+1 & "到" & i+10 & "的数据个数是:" & n
end sub