用VB的循环语句求1到100的奇数和与偶数积
Private Sub Form_Click()Dim i As Integer, sum As Integer, aa As Double aa = 1 For i = 1 To 100 If i Mod 2 = 0 Then aa = aa * i Else sum = sum + i End If Next i Debug.Print aa, sum End Sub
用VB写出1-100的所有奇数和偶数和
Private Sub Command1_Click()Dim i, sum1, sum2 As Integer sum1 = 0 sum2 = 0 For i = 1 To 100 If i Mod 2 = 1 Then sum1 = sum1 + i Else sum2 = sum2 + i End If Next i Print "奇数和为" & sum1 Print "偶数和为" & sum2 End Sub ...
用VB编程求1-100之间的奇数和与偶数和之差
for i=1 to 10 if i mod 2 then js=i=js else os=os+i next msgbox "偶数和-奇数和=" & os-js
急需vb编程求100以内所有奇数和及所有偶数和
方法一:通过按钮“求2到100之间的偶数和”,代码如下:vb Private Sub Command1_Click()Dim i As Integer Dim s As Integer s = 0 For i = 2 To 100 Step 2 s = s + i Next i Print "2到100的所有偶数和是:" & s End Sub 方法二:通过按钮“方法2”,代码如下:vb Private Sub...
VB用for 循环算1-100的奇数跟偶数有多少个?
q = 0: e = 0 For i = 1 To 100 If i Mod 2 = 0 Then e = e + 1 Else q = q + 1 End If Next Print "奇数个数=";q, "偶数个数=";e
跪求用VB编程计算1~100的奇数.偶数.整数和??
As Integer, sumO As Integer, sumZ As Integer, i As Integer Private Sub Form_Load()For i = 1 To 100 sumZ = sumZ + i If i Mod 2 = 0 Then sumO = sumO + i Else sumJ = sumJ + i End If Next Text1.Text = sumZ & vbCrLf & sumJ & vbCrLf & sumO End Sub ...
用vb算1至100内所有偶数,所有奇数,所有数的和
Private Sub Form_Click()Dim ou%, ji%, all For i = 1 To 100 If i Mod 2 = 0 Then '判断是不是偶数 ou = ou + i '如果是偶数就累加在ou上 Else ji = ji + i '奇数累加在ji上 End If all = all + i Next Print "偶数和:" & ou Print "奇数和:" & ji Pri...
VB DO循环求1~100的偶数积
Dim j As Double Dim i As Integer j = 1 i = 2 Do While i <= 100 j = j * i i = i + 2 Loop Print j 答案:3.4243224702512E+79
用vb从1加到100的程序怎么写
Private Sub Form_Click()Dim sum1 As Long, sum2 As Long, sum3 As Long, j As Long, n As Long For j = 1 To 100 sum1 = sum1 + j If j Mod 2 = 0 Then sum3 = sum3 + j Else sum2 = sum2 + j End If Next Me.Cls Print "整数和:"; sum1 Print "奇数和:"...
VB程序设计中如何产生随机数并分别求奇数和偶数的和
Private Sub Command1_Click()Randomize Timer For i = 1 To 100 x = Int(Rnd() * 90 + 10)If x Mod 2 = 0 Then m = m + x Else n = n + x End If Next Print "偶数和:"; Str(m)Print "奇数和:"; Str(n)End Sub 随机产生100个两位数,并分别求出奇数、偶数和 ...