with this codes i created rectangle image with a line inside that has to mimic a single clock.
Dim MyGraphics As graphics=e.graphics
my graphics.Draw Rectangle(pens.colour,x1,X2,y1,Y2):whereby x1=60,x2=70,y1=80,y2=90,and choosen colour
my graphics.Draw line(pens.colour,x1,x2,y1,y2):whereby x1=60,x2=70,y1=100,y2=120,and also choosen colour.

Now help me with ideas and solution here.the hand or line within the square has to rotate continually.now as a clue,as our lecture prescribed,under line,one group of X and Y axis has to remain constant or steady,while other y and x axis has to change now instead of using numbers we have to use variables eg lets say x1 which is 60 and y1 which is 100 are the ones to remain constant.we have to change them to or create them as variables(as in like num1 and num2) and make them change value so the line rotate continually that is continually changing.mow what are those rotating codes or variables for the hand,thus how are you going to implement those variables to make the hand to continually rotate.

Couple of ways you can do it. I caused the drawing iterations with a Timer event in a Timer control...that's probably the easiest.

Bottom line is that you have to have a center point (what your instructor calls "constant"). Draw a circle with this point as it's center.

Next you have to have variables for a pair of points...one to draw a line to, the other to keep track of where you have ALREADY drawn a line to. The reason for this is because, in graphics methods, you have to draw another line over the top of the old line to "erase" it, then draw your new line to the new point. This gives the illusion of a moving hand.

To figure out the location of the "new" point, do some trig to do the rotation (don't forget the offset caused by the center point!). Then draw a "background" colored line to erase the old line, draw a "foreground" colored line to make the new line. Then re-draw the original circle so you don't get the gaps caused by the erasure. Then save the new point as the old point and you're ready for the next iteration.

I hope this isn't too confusing. Just take small steps, look in the VB help file for the graphics methods' syntax, and find a formula for point rotations.

Good luck!

This article has been dead for over six months. Start a new discussion instead.