Results 1 to 10 of 10

Thread: [RESOLVED] weird error?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2012
    Posts
    142

    Resolved [RESOLVED] weird error?

    I have this code:
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

    Dim lx As Integer = 41
    Dim ly As Integer = 291
    Dim stoprise As Integer = 175
    Dim stopright As Integer = 100
    Dim xsize As Integer = PictureBox1.Width
    Dim ysize As Integer = PictureBox1.Height
    Dim pbx As Double = PictureBox1.Location.X
    Dim pby As Double = PictureBox1.Location.Y

    If pbx < stopright Then
    pbx = pbx + 1
    xsize = xsize - 1
    End If
    If pby > stoprise Then
    pby = pby - 1
    ysize = ysize - 7
    End If

    If pbx = stopright And pby = stoprise Then
    Timer1.Stop()
    End If
    End Sub

    It does not work, the picturebox doesn't move or resize at all.
    Last edited by ikdekker; Jan 28th, 2012 at 01:36 PM.

  2. #2
    Hyperactive Member
    Join Date
    Jan 2012
    Location
    Salt Lake City
    Posts
    313

    Re: weird error?

    do you expect us to run it? what is the error?

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2012
    Posts
    142

    Re: weird error?

    I am sorry, I edited it.

  4. #4
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,686

    Re: weird error?

    Quote Originally Posted by ikdekker View Post
    I have this code:
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

    Dim lx As Integer = 41
    Dim ly As Integer = 291
    Dim stoprise As Integer = 175
    Dim stopright As Integer = 100
    Dim xsize As Integer = PictureBox1.Width
    Dim ysize As Integer = PictureBox1.Height
    Dim pbx As Double = PictureBox1.Location.X
    Dim pby As Double = PictureBox1.Location.Y

    If pbx < stopright Then
    pbx = pbx + 1
    xsize = xsize - 1
    End If
    If pby > stoprise Then
    pby = pby - 1
    ysize = ysize - 7
    End If

    If pbx = stopright And pby = stoprise Then
    Timer1.Stop()
    End If
    End Sub

    It does not work, the picturebox doesn't move or resize at all.
    The picture box is not moving or resizing because you have not told it too. All you have done with the picture box is request information about its location, width and height.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jan 2012
    Posts
    142

    Re: weird error?

    what do I have to do then, I thought this would move it.
    pbx = pbx + 1
    xsize = xsize - 1

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jan 2012
    Posts
    142

    Re: weird error?

    I also tried .top and .left

  7. #7
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    39,041

    Re: weird error?

    Top and Left would change the location, but those other two would do nothing. They are value types that hold the values that you put into them (Integers, all). Changing them doesn't change the locations that they came from.
    My usual boring signature: Nothing

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Jan 2012
    Posts
    142

    Re: weird error?

    So what do I change?

  9. #9
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    39,041

    Re: weird error?

    .Width and .Height would change the size, whereas .Top and .Left would change the position.
    My usual boring signature: Nothing

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Jan 2012
    Posts
    142

    Re: weird error?

    I got most of it working now, removed the 'dimming' I have this now, but it moves left up and not right up.
    Code:
    If PictureBox1.Left < 100 Then
                PictureBox1.Left += 1
                PictureBox1.Width = PictureBox1.Width - 7
            End If
            If PictureBox1.Top > 175 Then
                PictureBox1.Top -= 1
                PictureBox1.Height = PictureBox1.Height - 1
            End If
    
            If PictureBox1.Left = 100 And PictureBox1.Top = 175 Then
                Timer1.Stop()
            End If

    EDIT: nvm, got it! thanks all.
    Last edited by ikdekker; Jan 29th, 2012 at 07:02 AM.

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