搜索
首页 电脑/网络 程序设计 VB

急需vb编程求100以内所有奇数和及所有偶数和

vb编程求100以内所有奇数和及所有偶数和

全部回答

2018-02-03

0 0

    一、按钮“求2到100之间的偶数和”代码如下: 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”代码如下: Private Sub Command2_Click() Dim i As Integer Dim s As Integer s = 0 For i = 2 To 100 If i Mod 2 = 0 Then s = s + i End If Next i Print "2到100的所有偶数和是:"; s End Sub 三、按钮“方法3”代码如下: Private Sub Command3_Click() Dim i As Integer Dim s As Integer s = 0 i = 2 Do If i Mod 2 = 0 Then s = s + i End If i = i + 1 Loop Until i > 100 Print "2到100的所有偶数和是:"; s End Sub 四、按钮“方法4”代码如下: Private Sub Command4_Click() Dim i As Integer Dim s As Integer s = 0 i = 2 Do s = s + i i = i + 2 Loop Until i > 100 Print "2到100的所有偶数和是:"; s End Sub Private Sub Command2_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 。
    。

2018-02-03

79 0

    Dim sumJ 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 。

2018-02-03

80 0

privatesubcommand1_click()d :dimiasjasintegetrfori=1to100step2a+=inextforj=2to100step2b+=jnextlabel1.text="一百以内的奇数相加是:"&convert.tostring(a)label2.text="一百以内的偶数相加是:"&convert.tostring(b)endsub

类似问题换一批

热度TOP

相关推荐
加载中...

热点搜索 换一换

电脑/网络
VB
程序设计
电脑装机
操作系统/系统故障
硬件
笔记本电脑
百度
互联网
反病毒
软件
程序设计
VB
数据库
C/C++
JAVA相关
C#/.NET
VC++
汇编语言
其他编程语言
VB
VB
举报
举报原因(必选):
取消确定举报