Results 1 to 3 of 3

Thread: Shapes and Moving PictureBox's

  1. #1
    Join Date
    Jun 2012
    Posts
    2,182
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Shapes and Moving PictureBox's

    Hey, I'm working on my first VB Program, but I can't figure a couple things out:

    1) Is there a way to create shapes like in lazarus?

    2) I ended up settling for a Picturebox, how do I move a picturebox? I tried
    Code:
    PictureBox1.Location.Y = PictureBox1.Location.Y + 5
    But that gave this error:
    Expression is a value and therefore cannot be the target of an assignment.

    I also tried this:
    Code:
    PictureBox1.Location.Offset(5, 5)
    That compiled, but it didn't do anything. Any help is appreciated!

    Thanks guys
    ~Not Handy
    Thx Euphemism and Vinyl for the awesome siggy and avatar!

  2. #2
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    PictureBox1.Location = new Drawing.Point(x, y)
    I am Ggzz..
    Hackintosher

  3. #3
    Join Date
    Jun 2012
    Posts
    2,182
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Whoops, I should have closed this, I found a solution. I used the += and -= operators like this:

    PictureBox1.Top -= 10

    But that brings me to another question. I'm trying to make a bouncing ball on my form, but its acting really strangly. Every run, the ball acts differently, it bounces in different ways, stuff like that. Am I doing something wrong? This is my Timer_Tick code.

    Code:
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            If PictureBox1.Top <= Me.Top Then
                UpOrDown = False
    
            End If
    
            If PictureBox1.Top + PictureBox1.Height >= Me.Height Then
                UpOrDown = True
    
            End If
    
            If PictureBox1.Left <= Me.Left Then
                LeftOrRight = False
    
            End If
    
            If PictureBox1.Left + PictureBox1.Width >= Me.Width Then
                LeftOrRight = True
    
            End If
    
            If UpOrDown = True Then
                PictureBox1.Top -= 10
            Else
                PictureBox1.Top += 10
            End If
    
            If LeftOrRight = True Then
                PictureBox1.Left -= 10
            Else
                PictureBox1.Left += 10
    
            End If
        End Sub
    Thanks for the help Brandon and whoever answers this question,

    E: Sorry for the lack of info, but It's hard to describe whats happening. I can send someone the .exe if they want to see whats happening. Basically, every time I run the program, the ball bounces at different spots. The "celing" it hits at the top and the "floor" it hits on the bottom are different, same with the "walls". Any Ideas?

    Footy
    Last edited by Footy; 10-14-2012 at 01:00 AM.
    Thx Euphemism and Vinyl for the awesome siggy and avatar!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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