This program is similar to the dice program except that we have added animation to the program. To add the animated effect, you need to include the timer control into your program. In the timer's properties windows, set the timer enabled property to false and the interval to 10. You can change the interval to any number you want.
Under the roll dice command, set the timer to enabled. You also need to create a subroutine and name it as roll. Under the roll subroutine, enter the code that display the different faces of the dice. To create the animated effect, you need to declare a global variable x and assign an initial value of 0 to it, then include the statement x=x+10 so that the value of x increase 10 units after an interval of 10 milliseconds. Finally, enter the statement under the timer subroutine . This code is to stop the timer. When you click the button roll dice, you will see that faces of the dice changes and then come to a stop
If x < 1000 Then
Timer1.Enabled = False
The Design Interface
The Run Time Interface
Copyright ® 2008 Dr.Liew Voon Kiong . All rights reserved |Contact: firstname.lastname@example.org