Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8131095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:58:33+00:00 2026-06-06T08:58:33+00:00

I am working on a simple program which requires me to be able to

  • 0

I am working on a simple program which requires me to be able to select a picture box and move it to a new location by dragging it with my mouse. This is all the relevant code I have come up with currently. However, when I run the program it tries to move to where I want it to go then it seems to revert back to its previous location.

Edit: it is in a container. If this is of any relevance.

Variables

Dim startx As Integer
Dim starty As Integer
Dim endy As Integer
Dim endx As Integer
Dim finalx As Integer
Dim finaly As Integer
Dim mdown As Boolean
Dim valx As Boolean
Dim valy As Boolean

Code to make image move

    Private Sub picbox_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles picbox.MouseDown
        startx = MousePosition.X
        starty = MousePosition.Y
        mdown = True
        valx = False
        valy = False
    End Sub

Private Sub Main_MouseMove(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove End Sub Private Sub picbox_MouseMove(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles picbox.MouseMove 'Check if mouse=down If mdown = True Then endx = (MousePosition.X - Me.Left) endy = (MousePosition.Y - Me.Top) If valy = False Then starty = endy - sender.top valy = True End If If valx = False Then startx = endx - sender.left valx = True End If sender.left = endx - startx sender.top = endy - starty End If End Sub Private Sub picbox_MouseUp(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles picbox.MouseUp mdown = False valx = False valy = False End Sub

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T08:58:34+00:00Added an answer on June 6, 2026 at 8:58 am

    Remove it out of the container. That is probably what is giving you the problems as your code works perfectly for me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple Delphi program that I'm working on, in which I am
I am working on making a simple drawing program. So far I am able
I am working on a simple CAD program which uses OpenGL to handle on-screen
I'm am currently working on a program in java which requires adding a small
I'm developing a simple program which makes a Python script executable, and I'm working
I've been working on a simple program in C# in which a Ball [X,Y]
I have the misfortune of working with a program which requires all filenames passed
I am kind of newbie on C++, and working on a simple program on
Working on a simple C program I'm stuck with an if test: int line_number
So I am working on a simple .NET program for work and hit a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.