Passing a value to another window

Hi,

once again *, yesterday, I’ve made a mistake: I created a property in a window, and use it in a method of this window.

Unfortunately, that integer variable is always 0. The relevant code is:

wTarget.IntVar = 15 wTarget.MyMethod

wTarget.IntVar is always 0.

To work-around that, I created a brand new variable in a Module, store it there in the code that will call wTarget.MyMethod. This works fine.

Am I so wrong in my “logic” ?

wTarget is a simple window that have a TextField to show an old value and ask the user to set a new, then press OK or Cancel. Nothing fancy in that case.

I already do that for another “feature” in the same project some times ago, but it tooks me times to realize that the code design was wrong (my code design).

Sometimes you will find that if you access a property or control of a window before doing

wTarget.IntVar = 15

then the window will be shown before that line has executed.

You may also be running into a problem with ‘implicit instantiation’
If you create a new window of TYPE wTarget, then
wTarget.IntVar = 15
will create another copy of the window.

(when debugging, check the number of open windows…)

Possibly the best advice here is amend the method to accept a parameter, and do this:

wTarget.myMethod( 15)

Thank you Jeff for your kind answer.

[quote=223233:@Jeff Tullin]Possibly the best advice here is amend the method to accept a parameter, and do this:

wTarget.myMethod( 15)[/quote]
While writing the text above, I was asking muself why I didn’t do that.