Results 1 to 4 of 4

Thread: .top of .image.location?

  1. #1

    Thread Starter
    Hyperactive Member francisstokes's Avatar
    Join Date
    May 2005
    Location
    Kent, England
    Posts
    272

    .top of .image.location?

    For moving my sprite around ive been using code like:

    VB Code:
    1. picturebox1.Image.Location = New Point (picturebox1.Image.Location.X +5, picturebox1.Image.Location.Y)

    Should i be using:

    VB Code:
    1. picturebox1.Image.Top

    Any responses would be appreciated.

  2. #2
    PowerPoster Keithuk's Avatar
    Join Date
    Jan 2004
    Location
    Staffordshire, England
    Posts
    2,235

    Re: .top of .image.location?

    Quote Originally Posted by francisstokes
    VB Code:
    1. picturebox1.Image.Location = New Point (picturebox1.Image.Location.X +5, picturebox1.Image.Location.Y)

    Should i be using:

    VB Code:
    1. picturebox1.Image.Top
    I'm presuming that picturebox1 is a PictureBox therefore it can have an Image but thats all, no Location.

    Remove the New.

    No you can't have picturebox1.Image.Top. Its either picturebox1.Top or Image.Top.

    The Point function is used to determine the colour of a specific point on a form.
    Keith

    I've been programming with VB for 20 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

  3. #3

    Thread Starter
    Hyperactive Member francisstokes's Avatar
    Join Date
    May 2005
    Location
    Kent, England
    Posts
    272

    Re: .top of .image.location?

    I don't know why i added the .image in.
    Its working fine (moving the sprite around the form) but i was wondering if it was better practise to use PictureBox1.Top.

  4. #4
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: .top of .image.location?

    Top is to change the vertical position (it sets or returns the distance to the top of the form), but in that line you are changing the horizontal position, so you need to use LEFT instead..
    VB Code:
    1. picturebox1.Left+= 5
    Also, in subforums like this (not language specific) you have to say which language/version you are using if you want a better help. I know it's VB.NET, but sometimes, as the syntax is similar, it's not very easy to find out.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width