重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
创新互联建站成立于2013年,是专业互联网技术服务公司,拥有项目成都做网站、成都网站制作网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元镇康做网站,已为上家服务,为镇康各地企业和个人服务,联系电话:13518219792
Dim a As Integer = Int(Rnd() * 100)
If a Mod 2 = 0 Then
MsgBox(a "是偶数")
Else
MsgBox(a "是奇数")
End If
End Sub
做成数组控件,index表示控件号(点虐 中修改+=)
伪代码:
s1=2*int(rnd)'俩偶数
s2=2*int(rnd)
select case index
case 0
s1=s1+1’俩奇数
s2=s2+1
case 2
s1=s1+1'1个奇数
case 3
s2=s2+1'1个奇数
end select
Private Sub Command1_Click()
Dim i As Integer
i = Text1.Text
If i Mod 2 = 0 Then
MsgBox "偶数"
Else
MsgBox "奇数"
End If
End Sub
这个同时判定可以采用多线程做。但是一般都是使用数组循环来统计。
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim A(100) As Integer
Dim n1 As Integer = 0
Dim n2 As Integer = 0
For i = 1 To 100
Randomize()
A(i) = Int(Rnd() * 1000 + 1)
If A(i) Mod 2 = 0 Then
n1 += 1
Else
n2 += 1
End If
Next
MsgBox("所产生的100个数字中偶数有" n1 "个,奇数有" n2 "个")
End Sub