Hey everyone,

I have a program that computes the distance between two elevations at a given point. I need to plot these lines to a picture. I'm having problems getting the lines to start in the correct spot. Here's the code I'm using:

Dim Gr As Graphics = PictureBox1.CreateGraphics()
        Dim skyBluePen As New Pen(Brushes.DeepSkyBlue)
        Gr.DrawLine(skyBluePen, 2, 1759, 103, 1768)

2 and 103 is the starting and ending distance (x1 and x2)
the 1700 values are y1 and y2.

I can't figure out a way to modify the given values to make sure they show up correctly on the picture box.

Your problem is your numbers are pixels and you need to set them to the right scale.
If each pixel is one foot then you are starting at pixel 2 and 1759 and going to pixel 103 and 1768. Depending on the size of your canvas these could be off the view. If you are working on topo you should have an idea on scaleing...1 pixel = 10 feet, etc.

Ok thanks. I can't get it to proportion correctly now.

Here's what I have

Dim Gr As Graphics = PictureBox1.CreateGraphics()
        Dim skyBluePen As New Pen(Brushes.DeepSkyBlue)
        Gr.DrawLine(skyBluePen, (2 * 5), Convert.ToInt16(1759 * 0.067), (103 * 5), Convert.ToInt16(1768 * 0.067 - 20))

I had to do -20 because the elevation ended up being about a pixel difference. Are there better solutions to this?

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