Yes, yes, I have an 'image' problem

Thank you Sascha & Emile, I’ll have a go at these in the morning. It’s late here in Aus. :slight_smile:
Will update if I get it to work. :smiley:

1 Like

Thats not going to work.
The picture will be out of scope as soon as the button code ends

Otherwise, its nearly exactly the same as the marked solution I gave earlier.

To create a global variable:
Add a module to the project
Add a property to the module (here, of type picture)
Set the scope of that to be public, not protected
Then it will work exactly like a global variable in VB6

Once you start to get into the code, you can think about making things more object oriented, if you want to. Nobody has to follow a style just because.

1 Like

Dim OffScreen As New Picture(Canvas1.Width, Canvas1.Height) could simply be moved to the Windows.Open*ing Event. But i’d guess both way’s, it would not go out of scope. At the End OffScreen is a Property of the Window and the above command would simply initiate reserving the memory and saving the reference.

The dim makes it local to wherever this line is executed.
If the open event of the window, it is out of scope when the open even ends.

OffScreen = New Picture(Canvas1.Width, Canvas1.Height)

would be different

1 Like

If OffScreen is a property of the window, you don’t Dim it, you simply write

OffScreen = New Picture(Canvas1.Width, Canvas1.Height)

Because it’s a window property it will be within scope of all code in the window.

Gosh. That’s true. I was wrong. :slight_smile:

And @Julia_Truchsess gave the correct “solution”. Thank you :slight_smile:

Sorry folks.

It seems that I am tired early in the day now ! :wink:

Thank you Jeff, adding in the Image_Holder = New Picture(Canvas1.width, Canvas1.Height) worked out.

1 Like