declaration of variable ignored in a sub-routine
Posted: Tue Aug 18, 2009 8:46 pm
It seems that the fonction dim work only the first time in a sub-routine:
A exemple:
object myform as form
Height=100
Width=100
object click as button
onclick=cluk
end object
end object
myform.ShowModal
sub cluk()
dim i as double
showmessage "i= "+str$(i)
if i< 1 then dim a as double
showmessage "a= "+str$(a)
i=1
end sub
If I click the first time I obtain:i=0 and a=0
the second time I expect i=0 but I obtain 1 and with the variable a I expect a bug because it`s not declared but I obtain a=0
I think that dim is ignored the second time.
A exemple:
object myform as form
Height=100
Width=100
object click as button
onclick=cluk
end object
end object
myform.ShowModal
sub cluk()
dim i as double
showmessage "i= "+str$(i)
if i< 1 then dim a as double
showmessage "a= "+str$(a)
i=1
end sub
If I click the first time I obtain:i=0 and a=0
the second time I expect i=0 but I obtain 1 and with the variable a I expect a bug because it`s not declared but I obtain a=0
I think that dim is ignored the second time.