[Gambas-user] How do I pass a user parameter from a dialog form?

Tobias Boege taboege at ...626...
Tue Nov 18 21:58:21 CET 2014


On Tue, 18 Nov 2014, Martin McGlensey wrote:
> Hello,
> 
>  
> 
> I have created a dialog form. As created by Gambas, it has an OK and Cancel
> button. I want to return three properties or an array from the form. One
> each for the three textboxes on the form.
> 
> I added a textbox to the form to test it. Call it Textbox1. Used the code
> below to add a property called "Login" to the Dialog:
> 
>  
> 
> Property Login As String
> 
> Private strLogin AS String
> 
>  
> 
> Private Function Login_Read()
> 
>                 Return txtTextbox1.Text
> 
> Return
> 
>  
> 
> Private Sub Login_Write(Value as String) as String
> 
>                 strLogin = Value
> 
> End
> 
>  
> 
> I call the Dialog from the main form by frmDialog.ShowModal. When I load the
> frmDialog, enter the text in the textbox and click OK. The Dialog closes but
> no value is returned to the main form.
> 
> If I explicitly set Login_Read to Return "XYZ" it works  properly. It
> returns "XYZ" to the main form. If I try to get the contents of
> Textbox1.Text it returns an empty string. There has got to be a way of
> returning the value of a textbox as a property of a dialog form.  I'd rather
> not use public variables on the main form as there are too many variables
> already.
> 
> Would you guys please point me in the right direction.
> 

This is a standard task and therefore a "template solution" evolved in the
Gambas sources. Attached is a project which shows how to do it cleanly, no
public variables and no auxiliary classes needed.

If you have a problem with the project and comments being German, I will
translate it for you...

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
-------------- next part --------------
A non-text attachment was scrubbed...
Name: login-form-0.0.2.tar.gz
Type: application/octet-stream
Size: 5130 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20141118/50988f89/attachment.obj>


More information about the User mailing list