当前位置: 代码迷 >> PB >> 关于PB变量的作用域
  详细解决方案

关于PB变量的作用域

热度:171   发布时间:2016-04-29 09:21:45.0
求助:关于PB变量的作用域
单击数据窗口排序
string str_column,str_format
str_column=dwo.name
debugbreak()

str_column=left(str_column,len(str_column) - 2)
if str_column=i_str_precolumn then
if i_int_clicktime=0 then
i_int_clicktime=1
str_format=str_column+" a"
else
i_int_clicktime=0
str_format=str_column+" d"
end if
else 
i_int_clicktime=1
str_format=str_column+" a"
end if
i_str_precolumn=str_column
dw_1.setsort(str_format)
dw_1.sort()

其中有两个变量:string i_str_precolumn=""
integer i_int_clicktime=0
为什么这两个变量不能定义成局部变量?定义成实例变量就可以了:

------解决方案--------------------
事件局部变量,在事件执行完后就销毁了,当然不行。
实例变量,是整个对象的属性。所以可以在事件开始部分取得其原有的值,在最后赋予新的值
  相关解决方案