您的位置:首页 > 编程语言 > VB

VB9中循环程序语言(残缺版)

2016-04-07 20:55 190 查看


第一种:
Private Sub Command1_Click()

i = 0

While i <= 100

s = s + i '

i = i + 1

Wend

Print s
End Sub

第二种:
Private Sub Command1_Click()
Text1 = ""
Dim a()
k = InputBox("请输入上限")
For i = 1 To k
If i Mod 2 = 0 And i Mod 3 = 0 And i Mod 5 <> 0 Then
j = j + 1
ReDim Preserve a(j)
a(j) = i
End If
Next i
For i = 1 To j
Text1 = Text1 & a(i) & " "
Next i
End Sub

第三种;
Private Sub Command1_Click()

For i=1 To 10

Randomize

a=Int(1000*Rnd)

sim=sum+a
msgbox
“是个随机数之和:”&sum
Next
End
Sub

第四种:
Private Sub Command1_Click()

cls

Dim n As Integer,

s as intenger

Dim a(10) AS Integer
n=1
while n<=10
a(n)=Int(Rnd*1000)
n=n+1
wend
n=1
while n<=10
print a(n)
n=n+1
wend
s=0
n=1
while n<=10
s=s+a(n)
n=n+1
wend
print s
End Sub

第五种;
Private Sub Command1_Click()
Cls
Font.Size=24

Print f(100)
End Sub
Private Function f(x As Integer) As Long

If x=1 Then

F=x

Else

F=x+f(x-1)

End If
End function
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: