饮用水源地规范化建设:看看我写的这个程序问题在哪?

来源:百度文库 编辑:高校问答 时间:2024/04/29 14:10:29
Private Sub Command1_Click()
If Val(Text1) = Val(Label2) + Val(Label4) Then
Label6.Caption = "√"
cj = cj + 10
Else
Label6.Caption = "ⅹ"
cj = cj - 5
End If
Label8.Caption = cj
Label2.Caption = Int(Rnd * 99 + 1)
Label4.Caption = Int(Rnd * 99 + 1)
End Sub

Private Sub Form_Load()
Randomize
Label2.Caption = Int(Rnd * 99 + 1)
Label4.Caption = Int(Rnd * 99 + 1)
End Sub
这是个加法计算,可是为什么执行命今后,Cj的值只在第一次运算的时候有效,第二次,第三次。。。以后都不会再变。

Cj首先应该是个全局变量或者来自数据库,系统运行的最初应该先初始化,在这个按钮的私有过程运行中,cj可能作为过程内部的变量进行运行,每次点击算次,但是没保存下来