vb:private定义
有如下两段代码:PrivateSubCommand1_Click()StaticyAsIntegerDimzAsInteger,xAsIntegern=10z=n+zy=...
有如下两段代码:
Private Sub Command1_Click()
Static y As Integer
Dim z As Integer, x As Integer
n = 10
z = n + z
y = y + z
x = x + z
Label1.Caption = x
Label2.Caption = y
Label3.Caption = z
End Sub
运行结果显示:10 30 10
Private x As Integer
Private Sub Command1_Click()
Static y As Integer
Dim z As Integer
n = 10
z = n + z
y = y + z
x = x + z
Label1.Caption = x
Label2.Caption = y
Label3.Caption = z
End Sub
运行结果显示30 30 10
不太明白,在不同地方对x定义是如何影响运行结果的,希望明白的朋友帮忙讲一下,谢谢。 展开
Private Sub Command1_Click()
Static y As Integer
Dim z As Integer, x As Integer
n = 10
z = n + z
y = y + z
x = x + z
Label1.Caption = x
Label2.Caption = y
Label3.Caption = z
End Sub
运行结果显示:10 30 10
Private x As Integer
Private Sub Command1_Click()
Static y As Integer
Dim z As Integer
n = 10
z = n + z
y = y + z
x = x + z
Label1.Caption = x
Label2.Caption = y
Label3.Caption = z
End Sub
运行结果显示30 30 10
不太明白,在不同地方对x定义是如何影响运行结果的,希望明白的朋友帮忙讲一下,谢谢。 展开
展开全部
你代码没贴全,第二段代码中的X在其他位置改变过数值了,第一段定义的是过程内变量,数值不会在其他地方改变,初始值为0
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询