Results 1 to 8 of 8

Thread: Moving a shape

  1. #1

    Thread Starter
    New Member BobTheGoldfish's Avatar
    Join Date
    Sep 2001
    Location
    A Goldfish Bowl
    Posts
    6

    Moving a shape

    Ok I am new to vb and i am struggling trying to get a shape object to move across the screen.
    So far i have made a timer that makes a label count up, but i cannot get the shape to move to it, this is the current code:
    Code:
    Private Sub Timer1_timer()
    Shape1.move (label1.caption)
    Label1.caption = Str(Val(Label1.caption) + Val(1))
    End Sub
    Any ideas?? If there is a better way of doing it then trhis would be good

    Cheers...
    Posted by Bob_the_Goldfish

    Also on irc.morat.net #Lobby

    http://freespace.morat.net/bob for unrelated rubbish

  2. #2
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Try setting Me.ScaleMode = 3 first, but not in the Timer routine; set it in the form view. Anyways, you could use this: Shape1.Left = Val(Label1.Caption), or Shape1.Top if you would like to move down.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  3. #3
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    Hy, I also started using shapes, that moved around. But soon you wil find that they start to flicker. consider to use the 'old' line and circle methods to paint a new picture in each timer-cycle
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  4. #4
    Hyperactive Member
    Join Date
    Aug 2001
    Location
    The Dark Side of the Moon
    Posts
    448
    Try using the TOP and LEFT properties. If you want it to move up, subtract it's TOP property, or down add it. Same for the left. Subtract the value to get it to go the direction it's named as. (There are no RIGHT and DOWN properties, they're part of the same thing, think of LEFT and TOP and X, Y)

    VB Code:
    1. Private Sub Timer1_Timer()
    2.      Shape.Top = Shape.Top - 10
    3. End Sub

  5. #5
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Instead of using a label you may want to use a Public/Private or Static varible.

    Also you're using twips, usually 15 twips=1 pixel but you can use screen.twipsperpixelx/y.

    For any intensive purpose though you'd want to set the scale of your form(or picturebox) to pixels(3).

  6. #6
    Hyperactive Member
    Join Date
    Aug 2001
    Location
    The Dark Side of the Moon
    Posts
    448
    usually 15 twips=1 pixel
    I thought twips are bigger than pixels. A twip is 1/1440th of an inch. And a the number of pixels on your monitor is determined by you resolution too.

  7. #7

    Thread Starter
    New Member BobTheGoldfish's Avatar
    Join Date
    Sep 2001
    Location
    A Goldfish Bowl
    Posts
    6
    Cheers all this helps loads.
    Posted by Bob_the_Goldfish

    Also on irc.morat.net #Lobby

    http://freespace.morat.net/bob for unrelated rubbish

  8. #8
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    VB Code:
    1. PixelX = TwipX / Screen.TwipsPerPixelX
    2. PixelY = TwipY / Screen.TwipsPerPixelY
    That's how you convert.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

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