VB简单编程

VB简单编程,第1张

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

x = Val(InputBox("输入奇数范围"))

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

欢迎分享,转载请注明来源:表白网

原文地址:https://h5.hunlipic.com/biaobai/3363204.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2024-02-24
下一篇2024-02-24

发表评论

登录后才能评论

评论列表(0条)

    保存