参考代码如下:
Dim
i
As
Integer,
k
As
Integer
Private
Sub
Command1_Click()
Timer2.Enabled
=
True
Timer1.Enabled
=
False
End
Sub
Private
Sub
Form_Load()
Timer1.Enabled
=
False
Timer2.Enabled
=
False
Timer1.Interval
=
600
Timer2.Interval
=
1000
End
Sub
Private
Sub
Timer1_Timer()
lblDisp(i).Caption
=
StrConv(i
+
1,
vbWide)
i
=
i
+
1
If
i
=
4
Then
Timer1.Enabled
=
False
End
Sub
Private
Sub
Timer2_Timer()
lblDisp(k).Caption
=
k
+
1
k
=
k
+
1
If
k
=
4
Then
Timer2.Enabled
=
False:
Timer1.Enabled
=
True
End
Sub
Private Sub Command1_Click() '第二题'辗转相除法求最大公约数
a = Val(Text1.Text)
b = Val(Text2.Text)
r = a Mod b
While r <> 0
a = b
b = r
r = a Mod b
Wend
Text3.Text = b
End Sub
Private Sub Command2_Click() '第三题
Const N = 10
Sum = 0: k = 1
For i = 1 To N
k = k * i
Sum = Sum + k
Next i
Print "1!+2!+3!+...+" & N & "!=" & Sum
End Sub
计算程序和运行结果如下:
Private Sub Command1_Click()
y = 2376000
p = 0.1345
i = 0
Print " 现在产值:"y
Do
i = i + 1
y = y * (1 + p)
Print i"年后产值:"y
Loop While y <2376000 * 2
Print i"年后产值可以翻一番。"
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)