Hi, I new here and currently learning as much programming languages as needed.
To start with the simplest programming language, VB.
I'm kind of having problems with producing an animation that uses the FOR Loop statement and the System.Threading.Thread.Sleep () command.
I've placed two objects (rectangles) together and would like to create a fake animation of 2nd rectangle yielding to the first object as if its pushing it. And place a line as a larger marker of movement.
The output should refresh the image in each time interval.
But instead of a multiple resizing and showing, the output only resizes the image once and directly goes to the final result.
For x = 0 To [[I]Limiting value w/c depends on input[/I]] Step 1
System.Threading.Thread.Sleep(1000)
RectangleShape1.Width = Val(a.Text) - x
RectangleShape2.Left = 500 - x
RectangleShape2.Width = Val(b.Text) + x
Line2.Left = RectangleShape2.Left
Line2.Visible = True
Line2.Refresh()
RectangleShape1.Refresh()
RectangleShape2.Refresh()
Next x
I'm stuck because it doesn't fake an animation, it acts like this code which imposes an instantaneous resizing.
RectangleShape1.Width = Val(a.Text) - Val(TextBox3.Text)
RectangleShape2.Left = 500 - Val(TextBox4.Text)
RectangleShape2.Width = Val(b.Text) + Val(TextBox4.Text)
Line2.Left = RectangleShape2.Left
Line2.Visible = True
Is there any other way to fake an animation or I have something wrong in my code?
Help would be greatly appreciated :)
By the way, I'm currently using VB2008 :(