Private?Sub?Button1_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?Button1.Click
創(chuàng)新互聯(lián)建站成立于2013年,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項目成都做網(wǎng)站、成都網(wǎng)站制作網(wǎng)站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元鎮(zhèn)康做網(wǎng)站,已為上家服務(wù),為鎮(zhèn)康各地企業(yè)和個人服務(wù),聯(lián)系電話:13518219792
Dim?a?As?Integer?=?Int(Rnd()?*?100)
If?a?Mod?2?=?0?Then
MsgBox(a??"是偶數(shù)")
Else
MsgBox(a??"是奇數(shù)")
End?If
End?Sub
做成數(shù)組控件,index表示控件號(點虐 中修改+=)
偽代碼:
s1=2*int(rnd)'倆偶數(shù)
s2=2*int(rnd)
select case index
case 0
s1=s1+1’倆奇數(shù)
s2=s2+1
case 2
s1=s1+1'1個奇數(shù)
case 3
s2=s2+1'1個奇數(shù)
end select
Private Sub Command1_Click()
Dim i As Integer
i = Text1.Text
If i Mod 2 = 0 Then
MsgBox "偶數(shù)"
Else
MsgBox "奇數(shù)"
End If
End Sub
這個同時判定可以采用多線程做。但是一般都是使用數(shù)組循環(huán)來統(tǒng)計。
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("所產(chǎn)生的100個數(shù)字中偶數(shù)有" n1 "個,奇數(shù)有" n2 "個")
End Sub