Is there a way to create a window with a string as a parameter input
Add a constructor to your window and specify the parameter(s) there. The constructor is just a method named “constructor” it will autocomplete for you. I would also turn off “implicit instance”. You can then create an instance of the window using something like
Dim w As New Window2("This is a parameter")
Note that if you create a Constructor method for the window you will see the following two lines automatically added to the Constructor method
// Calling the overridden superclass constructor.
Code placed before these statements will be executed before the controls on the window are instantiated. Code placed after these lines will be executed after all of the controls on the window are instantiated. The following is the code in a Constructor for an alert window that I place in all of my projects.
[code] // set some variables so when the Super is called below and the controls are
// opened they will have the values that they need to do their thing. The
// comments on the lines below explain what the above parameters are for
theMsg = msg // general alert message
theExplain = explain // explanation of alert
aCaption = aCap // action button caption
cCaption = cCap // cancel button caption (invisible if “”)
oCaption = oCap // other button caption (invisible if “”)
defaultBtn = defaultB // button to show as default (a,c,o none if “”)
cancelBtn = cancelB // button to act as cancel button (a,c,o none if “”)
iconType = iType // type of icon to display 0=note, 1=caution, 2=stop
// Calling the overridden superclass constructor now that we have stored needed info
setup // finish setting up the alert window[/code]
This is setting 8 properties of the window such that they will be available as the controls of the window are being instantiated and that is why they are set before the “Super.Constructor” line is executed.
Thank very much, tonight I’ll try.
Xojo constructors are not really constructors like in other languages, they are just regular methods which follow a naming convention and are being called at a certain time by the Xojo framework. They are not called on instantiation of an object. For example window constructors are executed after the window and all controls have been instantiated.
Also note, that in the window’s constructor you should not set or get the values of properties in code which you also could manipulate in the Property Editor. These properties are set to the values entered in the Property Editor after the constructor has executed and before the Open event. So set such properties in code in the Open event only.