Passing a variable to a module ?
Posted
#1
(In Topic #633)
Regular

Just so you know : I have been back to square 1 with everything on my computer. A very huge power surge played havoc on numerous things electric in our neighbourhood, including my computer, its HD and external backup HD that happened just then to be connected. And yes, in spite of an apparently useless surge protector. Had to spend every free second to recover what still could be recovered. Back to business.
Question : How can I pass a variable to a module?
Some of you will remember my post on how to store data within an application (programme?) and building on a suggestion from Bruce, I put my data in a module like this :
Code (gambas)
- ' Module DataCloset
- ' Receive a value for x from Button1_Click() ???
- x = 2 'just an example
- Case 1
- NamesStr$ = "John,Michael,Harry,Liam,William,Oliver,James,Peter"
- Case 2
- NamesStr$ = "Isabelle,Yvonne,Mary,Patricia,Olivia,Emma,Eve,Amalia,Petra,Fleur"
- Case 3
- NamesStr$ = "Fido,Tiger,Bella,Ginger,Momo,Chibi"
- Return NamesStr$
In Fmain I have a Button that should retrieve the list I want (just for now, later to be replaced by a proper choose routine.)
Old african saying:
You eat an elephant one small bite at a time.
You eat an elephant one small bite at a time.
Posted
Regular

Doctor Watson said
…Question : How can I pass a variable to a module?…
I'm not totally clear on how you want to implement this, but one approach is to create a Public variable in your module.
So maybe:-
Code (gambas)
…and then in FMain:-
…or instead of declaring a Public variable, maybe pass the list number as an argument to the Data function, something like this:-
I hope that is clear.
Posted
Regular

The first solution does exactly what I'm looking for.
I just forgot about about the Public declaration. Oh dear …
Old african saying:
You eat an elephant one small bite at a time.
You eat an elephant one small bite at a time.
1 guest and 0 members have just viewed this.



