在窗体上有两个标签框名称分别为label1和label2 标题分别为随机数和结果 两个文本
1个回答
展开全部
不要太简单。。。。。。
首先定义一个全局数组变量
Dim a() As Long
Private Sub Command1_click() '产生随机数
Dim Str As String
Str = ""
ReDim a(29)
For i = 0 To 29
Randomize
a(i) = Clng(Rnd *200+1)
If Str = "" Then Str = Cstr(a(i)) Else Str = Str & " " & a(i)
Next
Text1.Text = Str
End Sub
Private Sub Command2_Click() '取奇数
Dim Str As String
Str = ""
For i = 0 To 29
If a(i) Mod 2 = 1 Then
If Str = "" Then Str = Cstr(a(i)) Else Str = Str & " " & a(i)
End If
Next
Text2.Text = Str
End Sub
Private Sub Command3_Click() '退出
End
End Sub
首先定义一个全局数组变量
Dim a() As Long
Private Sub Command1_click() '产生随机数
Dim Str As String
Str = ""
ReDim a(29)
For i = 0 To 29
Randomize
a(i) = Clng(Rnd *200+1)
If Str = "" Then Str = Cstr(a(i)) Else Str = Str & " " & a(i)
Next
Text1.Text = Str
End Sub
Private Sub Command2_Click() '取奇数
Dim Str As String
Str = ""
For i = 0 To 29
If a(i) Mod 2 = 1 Then
If Str = "" Then Str = Cstr(a(i)) Else Str = Str & " " & a(i)
End If
Next
Text2.Text = Str
End Sub
Private Sub Command3_Click() '退出
End
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询