Dim i As Integer
For i = 1 To N
If i Mod 2 = 0 Then
Num = Num + i
End If
Next i
Label1captain = Num
或者是
Dim x As Long, y As Long, sumX As Long, sumY As Long
y = Val(InputBox("输入偶数范围"))
For i = 1 To x Step 2
sumX = sumX + i
Next
For i = 2 To y Step 2
sumY = sumY + i
Next
Label1captain "奇数和为:" & sumX & "偶数和为:" & sumY
这是两个金字塔
Private Sub Form_Load()
AutoRedraw = True
Dim i As Integer, _
Line_Num As Integer
Line_Num = Val(InputBox("请输入行数", "设置", "10"))
For i = 1 To Line_Num
Print Space(Line_Num - i); String(2 i - 1, 42); Space(2 (Line_Num - i) + 1); String(2 i - 1, 42)
Next
End Sub
欢迎分享,转载请注明来源:表白网
评论列表(0条)