Form location doesn't seem to exist.

Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.Location = New Point(Me.Location.X - 10, Me.Location.Y - 10)/// move the form left & up by 10 pixels each way.
    End Sub
hope this helps :)
 
Yes, I know how to change the location, but the location doesnt appear to exist... if I have a form called Form1 made with the GUI form maker, when I attempt to move it, location does not appear to be a member of the form. (i.e. Form1.location doesnt exist). Im sure Im doing something really stupid, but Im just starting with VB (though I am pretty good at C/C++)
 
Me refers to the class that you are currently coding in. So if you put Me in form it will refer to the form, if you put Me in a button class it will refer to that button.
 
The reason you cant do Form1.Location is because all Forms in .NET are classes; you cant change the location of a class, obviously, only of an instance of the class.

You could do this:
Code:
Dim frm As New Form1() create a new instance of the Form1 class

frm.Location = New Point(10, 20) move the form
frm.Show() show the form
and it would work.

As mutant said, Me refers to the *instance* of the class that you are currently working in.
 
Me will always refer to the class instance you are inside, not the object that is recieving an event.

I believe mutant was referring to if you made your own button class:
Code:
Public Class MyButton : Inherits Button
  Public Sub ChangeText()
    Me.Text = "Moooo"
  End Sub
End Class
If you put that button on your form and called its newly made ChangeText() method, the text of the button would change to "Moooo".
 
Back
Top