Thread: [Gambas-user] How do I pass a user parameter from a dialog form?
                
                Brought to you by:
                
                    gambas
                    
                
            
            
        
        
        
    | 
     
      
      
      From: Martin M. <mmc...@fr...> - 2014-11-18 19:43:10
       
   | 
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.
 
Thanks,
Marty
 
 
 | 
| 
     
      
      
      From: roberto <rh...@ya...> - 2014-11-18 20:12:03
       
   | 
Hi Marty, you would use a new class file were store your variables. In this case the class is a bridge from your dialog to main form Regards Il 18/11/2014 20:42, Martin McGlensey ha scritto: > 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. > > > > Thanks, > > Marty > > > > > > ------------------------------------------------------------------------------ > 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 > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gambas-user >  | 
| 
     
      
      
      From: Roki <n.r...@gm...> - 2014-11-18 20:23:59
       
   | 
try this:
1) in main form
Property Login As String
Private strLogin AS String
Private Function Login_Read()
       Return strLogin
End
Private Sub Login_Write(Value as String) as String
        strLogin = Value
End
Private sub Button1_Click()
	dim f as new frmDialog <-- Your name of dialog form
	if f.ShowModal() Then return
	TextBox1.Text = strLogin
End
2) On DialogForm
    when you click on OK button
    Private Sub btnOK_Click()
    FMain.Login = TextBox1.Text < ---I guess  this is the name of TextBox on your dialog form
    End
And 3) I'm sorry for my bad English, and
I  guess this  will help!
	
On 18.11.2014 20:42, 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.
>
>   
>
> Thanks,
>
> Marty
>
>   
>
>   
>
> ------------------------------------------------------------------------------
> 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
> Gam...@li...
> https://lists.sourceforge.net/lists/listinfo/gambas-user
 | 
| 
     
      
      
      From: Fabien B. <gam...@gm...> - 2014-11-18 21:14:15
       
   | 
the common way is : In the form : Static Public Param1 as string Static Public Param2 as String Static Public Param3 as string Public Function Run(hParam1 as string, hParam2 as string, hParam3 as string) as boolean dim hForm as FDialog Return Not Me.ShowDialog() end Public Sub Form_Open1 TextBox1.Text = Param1 TextBox2.Text = Param2 TextBox3.Text = Param3 end Public Sub btnValidate_Click() Param1 =TextBox1.Text Param2 = TextBox2.Text Param3 = TextBox3.Text me.Close(True) End Public sub btnCancel_Click() Me.Close End Calling the form : FDialog.Param1 = "myparam1" FDialog.Param2 = "MyParam2" FDialog.Param3 = "MyParam3" If Not Fdialog.Run() then Print FDialog.Param1 ,FDialog.Param2 ,FDialog.Param3 endif  | 
| 
     
      
      
      From: Tobias B. <ta...@gm...> - 2014-11-18 21:01:39
       
  
        
          
            Attachments:
            login-form-0.0.2.tar.gz
          
        
       
     | 
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  | 
| 
     
      
      
      From: Rolf-Werner E. <eil...@t-...> - 2014-11-19 08:13:44
       
   | 
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  | 
| 
     
      
      
      From: Fabien B. <gam...@gm...> - 2014-11-19 08:24:52
       
   | 
Function sub and procedure are the same . It's just a use Le 19 nov. 2014 09:14, "Rolf-Werner Eilert" <eil...@t-...> 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 > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gambas-user >  | 
| 
     
      
      
      From: Tobias B. <ta...@gm...> - 2014-11-19 15:40:59
       
   | 
On Wed, 19 Nov 2014, Rolf-Werner Eilert wrote: > > 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.). > _call is a special method that allows you to use an object like a function. It is documented in the "Special methods" section[0]. However, it is not mandatory here. In Gambas sources you mostly see a function named Run() instead. I just like the _call() syntax better. > 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.) > Definitely! Usually I do that, but sometimes signatures change when I develop the code further. I must have overseen that spot. Anyway, in Gambas Sub, Procedure and Function are mutually interchangeable. Regards, Tobi [0] http://gambaswiki.org/wiki/cat/special -- "There's an old saying: Don't change anything... ever!" -- Mr. Monk  | 
| 
     
      
      
      From: Rolf-Werner E. <eil...@t-...> - 2014-12-17 11:10:16
       
   | 
Hi Tobias, I found the solution... Make a collection array within the dialog or within the _call function, then add the items and Return aMyCollection will do the rest. Need another cup of coffee :) 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=164703151&iu=/4140/ostg.clktrk _______________________________________________ Gambas-user mailing list Gam...@li... https://lists.sourceforge.net/lists/listinfo/gambas-user  | 
| 
     
      
      
      From: Rolf-Werner E. <eil...@t-...> - 2014-12-17 10:29:46
       
   | 
Hi Tobias, After some time, I had the chance to look at this thing again: Am 19.11.2014 16:37, schrieb Tobias Boege: > On Wed, 19 Nov 2014, Rolf-Werner Eilert wrote: >>> 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.). >> > > _call is a special method that allows you to use an object like a function. > It is documented in the "Special methods" section[0]. > > However, it is not mandatory here. In Gambas sources you mostly see a > function named Run() instead. I just like the _call() syntax better. > >> 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.) >> > > Definitely! Usually I do that, but sometimes signatures change when I > develop the code further. I must have overseen that spot. Anyway, in > Gambas Sub, Procedure and Function are mutually interchangeable. > > Regards, > Tobi > > [0] http://gambaswiki.org/wiki/cat/special > My question is, when I have more than a few parameters to state, how can I achieve that? Now it is Return ["name": txtName.Text, "password": txtPassword.Text] but when I have 200 or more things to pass? Or is the collection thing too slowly for such a number of items? Rolf  | 
| 
     
      
      
      From: Fabien B. <gam...@gm...> - 2014-12-17 10:41:23
       
   | 
you can use collection too I use collections to manage hundreds images in gb.map cache for example. I don't see other simple way in your case 2014-12-17 11:29 GMT+01:00 Rolf-Werner Eilert <eil...@t-...>: > Hi Tobias, > > After some time, I had the chance to look at this thing again: > > Am 19.11.2014 16:37, schrieb Tobias Boege: >> On Wed, 19 Nov 2014, Rolf-Werner Eilert wrote: >>>> 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.). >>> >> >> _call is a special method that allows you to use an object like a function. >> It is documented in the "Special methods" section[0]. >> >> However, it is not mandatory here. In Gambas sources you mostly see a >> function named Run() instead. I just like the _call() syntax better. >> >>> 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.) >>> >> >> Definitely! Usually I do that, but sometimes signatures change when I >> develop the code further. I must have overseen that spot. Anyway, in >> Gambas Sub, Procedure and Function are mutually interchangeable. >> >> Regards, >> Tobi >> >> [0] http://gambaswiki.org/wiki/cat/special >> > > > My question is, when I have more than a few parameters to state, how can > I achieve that? > > Now it is > > Return ["name": txtName.Text, "password": txtPassword.Text] > > but when I have 200 or more things to pass? Or is the collection thing > too slowly for such a number of items? > > 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=164703151&iu=/4140/ostg.clktrk > _______________________________________________ > Gambas-user mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gambas-user -- Fabien Bodard  |