Self vs Me. Sometimes you can get away with using Me in code that would be better (in the sense of clarity) by using Self. I try and stay on the right side of the street when coding to avoid confusion.
The documentation says in an entry on the topic of Me vs. Self:
If you use the Me prefix outside of a control’s event handler on a DesktopWindow/WebPage/MobileScreen (such as in a method), then Me will work the same as Self. To prevent confusion, you should refrain from using the Me prefix outside of control event handlers on DesktopWindows/WebPages/MobileScreens.
When working with classes and subclasses you have added to your project, you should always use Self (or nothing since Self is the default). This is true even if you create a control subclass and are implementing its event handlers. Again, you only use Me when in the event handler for a control (or class) that is added to a DesktopWindow/WebPage/MobileScreen.
You could take away from this, that you should never see the prefix Me outside the event handler of a control.
Am I correct in observing that another valid location for Me is in the Methods of a Class whose super is Canvas?
I have such a Class. One of the properties of a Canvas is Window. If you are writing Methods for this Class and you wanted to refer to the Window in which it happens to exist (say to figure out the size of that Window) is it not appropriate to write something like
Var widthOfParentWindow As Integer
widthOfParentWindow = Me.Window.Width
Or is it preferable to write
Var widthOfParentWindow As Integer
widthOfParentWindow = Self.Window.Width
For some reason, I am concerned that the Self will cause “confusion” when the code is actually being run as a method in a control that lives in a Window.
The example in the Documentation for DesktopControl.Window is:
This code gets the parent window’s Title property.
MessageBox(Me.Window.Title)
So Me is being used here in this example. Would this better have been written
MessageBox(Self.Window.Title)
??