Jump to content
Xtreme .Net Talk

Recommended Posts

  • Leaders
Posted

   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 :)

Posted
Yes, I know how to change the location, but the location doesn't 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 doesn't exist). I'm sure I'm doing something really stupid, but I'm just starting with VB (though I am pretty good at C/C++)
  • *Experts*
Posted
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.
  • *Experts*
Posted

The reason you can't do Form1.Location is because all Forms in .NET are classes; you can't change the location of a class, obviously, only of an instance of the class.

 

You could do this:

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.

  • *Experts*
Posted

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:

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".

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...