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

Fabien Bodard gambas.fr at ...626...
Wed Nov 19 09:24:45 CET 2014


Function sub and procedure are the same . It's just a use
Le 19 nov. 2014 09:14, "Rolf-Werner Eilert" <eilert-sprachen at ...221...> a
écrit :

>
>
> Am 18.11.2014 21:58, schrieb Tobias Boege:
> > 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
> >
> >
>
>
> Thanks for that example. Never realised there would be this way to do
> it. It does indeed save a lot of trouble with values from dialogs. On
> the other hand, it means changing the form calls I'm used to from a
> simple "formxyz.ShowModal" to "DIM hForm As New formxyz" "aCollection =
> hForm(...)".
>
> Let me ask two things I stumbled over when studying the code:
>
> Where would I find this "call" thing in the documentation? F2 doesn't
> react to event calls, and I cannot find it under the event descriptions
> (like Event Management etc.).
>
> Why is a SUB used with a Return value? Wouldn't it be more up to
> standards to use a FUNCTION instead? (As far as I understand, a SUB is a
> function without a return value, one that would be of type "void" under C.)
>
>
>
>
> Regards
> Rolf
>
>
> ------------------------------------------------------------------------------
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
> with Interactivity, Sharing, Native Excel Exports, App Integration & more
> Get technology previously reserved for billion-dollar corporations, FREE
>
> http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



More information about the User mailing list