kobolds ha scritto: > in order to get return value from a form , I create a variable in the form > > in ftest > public retun_value as boolean =false > > public sub btnOK_click() > return_value = true > me.close > end > > public sub btncancel_click() > return_value = false > me.close > end > > -------------------------------- > from Fmain > public sub btnTest_click() > dim m_ftest = new ftest > m_ftest.showmodal > if m_ftest.return_value = false then > ...... > endif > end > > when I run I get error object not found on "if m_ftest.return_value = false > then" . my guess is after the ftest close , the ref memory also gone . this > shouldn't be happen like this right ? > You are right - the form (better, the instance of the class) has gone. There are three solutions.
1) Read the documentation. ShowModal() can return a value, which is the one passed to FTest.Close(). It has some limitations (if you close the form using the "X" button, this value will be 0, if I well remember). This should be the canonical solution. 2) Don't know if it works. You could make *two* references to ftest (ref1=new ftest; ref2=ref1). When the form closes, there is still a reference; don't know what precisely do a form when it closes. On other platforms, a Close() simply hides the form, so this method works, but with gambas Close() normally destroys the form, so who knows what happens? This is a dirty solution. 3) Don't know if it works either. You could use Visible=False in FTest, instead of closing it. Again, on other platforms this works. The form is not destroyed and, if gambas is smart enough, it understands that a hidden form can not be modal. Ciao, -- Doriano Blengino "Listen twice before you speak. This is why we have two ears, but only one mouth." ------------------------------------------------------------------------------ Check out the new SourceForge.net Marketplace. It is the best place to buy or sell services for just about anything Open Source. http://p.sf.net/sfu/Xq1LFB _______________________________________________ Gambas-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/gambas-user
