展开全部
Private Sub Command1_Click()
Dim a, b, c, d, e As Integer
a = CInt(Text1.Text)
b = CInt(Text2.Text)
If a < b Then
e = 1
Else
e = -1
End If
For c = a To b Step e
If c Mod 2 = 0 Then
d = d + c
End If
Next
MsgBox a & "到" & b & "之间的所有偶数和为" & d
End Sub
Dim a, b, c, d, e As Integer
a = CInt(Text1.Text)
b = CInt(Text2.Text)
If a < b Then
e = 1
Else
e = -1
End If
For c = a To b Step e
If c Mod 2 = 0 Then
d = d + c
End If
Next
MsgBox a & "到" & b & "之间的所有偶数和为" & d
End Sub
展开全部
感觉一楼的下面这几个语句用得不错:
If a < b Then
e = 1
Else
e = -1
End If
For c = a To b Step e
If a < b Then
e = 1
Else
e = -1
End If
For c = a To b Step e
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Command1_Click()
Dim a, b, c, temp, i As Integer
a = Val(Text1.Text)
b = Val(Text2.Text)
If a > b Then temp = b: b = a: a = temp
For i = a To b
If i Mod 2 = 0 Then c = c + i
Next i
Text3.Text = c
End Sub
Dim a, b, c, temp, i As Integer
a = Val(Text1.Text)
b = Val(Text2.Text)
If a > b Then temp = b: b = a: a = temp
For i = a To b
If i Mod 2 = 0 Then c = c + i
Next i
Text3.Text = c
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询