|
-
Jan 28th, 2012, 12:12 PM
#1
Thread Starter
Addicted Member
[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.
-
Jan 28th, 2012, 01:13 PM
#2
Hyperactive Member
Re: weird error?
do you expect us to run it? what is the error?
-
Jan 28th, 2012, 01:35 PM
#3
Thread Starter
Addicted Member
-
Jan 28th, 2012, 01:38 PM
#4
Re: weird error?
 Originally Posted by ikdekker
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.
-
Jan 28th, 2012, 02:02 PM
#5
Thread Starter
Addicted Member
Re: weird error?
what do I have to do then, I thought this would move it.
pbx = pbx + 1
xsize = xsize - 1
-
Jan 28th, 2012, 02:24 PM
#6
Thread Starter
Addicted Member
Re: weird error?
I also tried .top and .left
-
Jan 28th, 2012, 02:28 PM
#7
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
 
-
Jan 28th, 2012, 02:32 PM
#8
Thread Starter
Addicted Member
-
Jan 28th, 2012, 05:44 PM
#9
Re: weird error?
.Width and .Height would change the size, whereas .Top and .Left would change the position.
My usual boring signature: Nothing
 
-
Jan 29th, 2012, 06:56 AM
#10
Thread Starter
Addicted Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|