juggernot
Well-known member
- Joined
- Sep 28, 2006
- Messages
- 173
- Programming Experience
- Beginner
I'm making a graphing program. Right now I'm trying to setup a grid according to the information the user gave on the form before. The user decides the max, min and interval values for x and y. I then use that information, and translate it into a 1000X1000 pixel graph. That's the plan at least, but my code isn't working quite right. The number of lines, and the space between them, seems to be incorrect. Could you look over my code and tell me where I went wrong?
VB.NET:
Dim point1 As New Point
Dim point2 As New Point
Dim graphic1 As System.Drawing.Graphics
Dim pixelsY As Integer
Dim pixelsX As Integer
Dim Xnumlines As Integer
Dim Ynumlines As Integer
Dim intcounter As Integer
Dim mypen As New System.Drawing.Pen(System.Drawing.Color.Black, 2)
'Determines the number of lines to draw
Ynumlines = gintYmax - gintYmin \ gintYinterval
Xnumlines = gintXmax - gintXmin \ gintXinterval
'Determines how many pixels between the lines
pixelsY = 1000 / Ynumlines
pixelsX = 1000 / Xnumlines
graphic1 = Me.CreateGraphics
For intcounter = 0 To Ynumlines Step 1
point1.X = 0
point1.Y = intcounter * pixelsY
point2.X = 1000
point2.Y = intcounter * pixelsY
graphic1.DrawLine(mypen, point1, point2)
intcounter += 1
Next