0

I need code for Visual Basic 2010 Express.

I am doing a project in school that is about making a pupil (picturebox2) follow the mouse so that students can follow where the mouse is during a lesson. It is supposed to be "stuck" inside of something that can hold it in a rectangular "prison" but still follow the mouses movement inside of it. The "prison" is placed at the bottom left corner, and about 200x200 in size.

I could use code for getting pb2 not going outside of the prison and how I can make pb2 to follow the mouse anyway.

Sample code:

PictureBox2.Text = e.X.ToString
PictureBox2.Text = e.Y.ToString

Me.PictureBox2.Location = New System.Drawing.Point(e.X, e.Y)
Dale K
  • 25,246
  • 15
  • 42
  • 71
  • please give sample code or what have you tried and did not work – ardhitama Mar 25 '20 at 13:21
  • PictureBox2.Text = e.X.ToString PictureBox2.Text = e.Y.ToString Me.PictureBox2.Location = New System.Drawing.Point(e.X, e.Y) This is the code i just to get the picturebox to follow my mouse, but I realized I needed it to be "stuck" inside Another box – Signe Näslund Mar 26 '20 at 15:55
  • And I could really use a code for how to tell pb2 that it has to stay inside of the prison. – Signe Näslund Mar 30 '20 at 06:56

0 Answers0