公共变量损失了价值 [英] Public variable losses the value

查看:67
本文介绍了公共变量损失了价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI 

我是编程新手,所以请原谅我的问题是天真的。

I am new to programming, so excuse me if my question is naive.

我宣布了一个公共变量并在子过程中为其赋值。 

I declared a public variable and assigned it a value in a sub procedure. 

当我尝试在另一个子过程中访问相同的变量时,为了获得在第一个过程中分配的值,变量保留其值(由第一个程序指定)当我第一次运行第二个程序时。 

When I try to access the same variable in another sub procedure, to get the value assigned in the first procedure the variable retains its value (as assigned by the first procedure) when I am run the second procedure first time. 

但是当我再次运行第二个程序时,公共变量的值自动设置为0.  ;

But when I run the second procedure again the public variable's value is automatically set to 0. 

有些人可以帮我理解这个吗?

Could some help me in understanding this?

谢谢!

Tushar

推荐答案

这个变量在Form模块中声明为Public吗?如果是这样,变量不完全适用于公共访问。如果要访问同一表单中的变量,请检查是否有任何其他代码重置该变量。
Is this variable declared Public in a Form module? If so the variable is not exactly for Public access. If you are accessing the variable inside the same Form, check if any other code resets the variable.


这篇关于公共变量损失了价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆