VB 2005 Express Drawline Help

  • Thread starter Thread starter Ian Tedridge
  • Start date Start date
I

Ian Tedridge

Can anybody help me with a small piece of coding ?

I have used some code to draw a square within my form, using the drawline
function with in the Form1_Paint event handler.

With in this square, I wish to draw a line which originates from the bottom
right hand corner, and is of a length with in the square. The idea to
produce a form of Dial Gauge.

The origin point will always stay the same place, but opposite end of the
line is dependent upon the value of a textbox (say 1 to 10). Swing of this
line should be between the 3 o'clock and 12 o'Clock Positions.

If somebody can help with a sample of coding that I can experiment with. it
would be greatly appreciated.

Regard
 
You're going to have to dust off your trig skills. If the value of the
textbox will indicate a percentage from 0 to 100, it might be easier.
You will have to figure a way to take that value and determine what
angle to draw the guage line at. If you let the 3 O'Clock position be
0 degrees and the 12 O'Clock position be 90 degrees. Then take the
percentage and multiply by 90 to get the angle. So 50% would be 45
degrees.

Once you know the angle you want, you will have to figure out the x,y
coordinates of the other end of the line. Using the law of sines or
cosines, you can take the origin point and the angle and the length of
the line to figure out the x,y coordinates of the opposite end.

Then you can draw your line using the two coordinate pairs.
 
Back
Top