2级VB的一道题,这个是怎么循环的,窗体上有TEXT1和TEXT2还有Command1命令按钮

[复制链接]
查看11 | 回复1 | 2011-3-19 11:35:22 | 显示全部楼层 |阅读模式
Dim y As Integer
Private Sub Command1_Click()
Dim x As Integer
x = 2
Text1.Text = fun2(fun1(x), y)
Text2.Text = fun1(x)
End Sub
Private Function fun1(x As Integer) As Integer
x = x y: y = x y
fun1 = x y
End Function
Private Function fun2(x As Integer, y As Integer) As Integer
fun2 = 2 * x y
End Function
回复

使用道具 举报

千问 | 2011-3-19 11:35:22 | 显示全部楼层
<pre id=\"best-answer-content\" class=\"reply-text mb10\">y作为全局变量,没有赋初值就参与运算了,缺省为0。
fun1:x=x y=2 0=2; y=x y=2 0=2; fun1=x y=2 2=4
Text2=fun2=2*x y=2*fun(1) y=2*4 2=10
Text1=fun1:x=x y=2 2=4; y=x y=4 2=6; fun1=x y=6 6=10
这是第一次运算,第二次运算同理可得。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行