Private Sub Command1_Click()
成都创新互联公司从2013年创立,先为白塔等服务建站,白塔等地企业,进行企业商务咨询服务。为白塔企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。
Dim i As Integer
i = Text1.Text
If i Mod 2 = 0 Then
MsgBox "偶数"
Else
MsgBox "奇数"
End If
End Sub
Dim sum As Integer
For i = 1 To 30
If i Mod 2 = 0 Then
sum = sum + i
End If
Next
这个同时判定可以采用多线程做。但是一般都是使用数组循环来统计。
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