Hi all,
I am trying to create a nested loop for a two dimensional array and then plot the data using Paint event handler. The array's length is 401 pts (0 included). Is there a better way to loop through the array other than writing it out 401 times?
Thanks in advance,
aman
I am trying to create a nested loop for a two dimensional array and then plot the data using Paint event handler. The array's length is 401 pts (0 included). Is there a better way to loop through the array other than writing it out 401 times?
Thanks in advance,
aman
VB.NET:
Imports System.Drawing.Drawing2D
Public Class Form1
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
Dim bluePen As New Pen(Color.Blue, 0)
Dim a0, b0, a1, b1, a2, b2, a3, b3, a4, b4, a5, b5, a6, b6, a7, b7, a8, b8, a9, b9, a10, b10 As Integer
a0 = 0 : b0 = 0
a1 = 5 : b1 = 10
a2 = 10 : b2 = 20
a3 = 15 : b3 = 30
a4 = 20 : b4 = 40
a5 = 25 : b5 = 50
a6 = 30 : b6 = 60
a7 = 35 : b7 = 70
a8 = 40 : b8 = 80
a9 = 45 : b9 = 90
a10 = 50 : b10 = 100
Dim p0 As New PointF(a0, b0)
Dim p1 As New PointF(a1, b1)
Dim p2 As New PointF(a2, b2)
Dim p3 As New PointF(a3, b3)
Dim p4 As New PointF(a4, b4)
Dim p5 As New PointF(a5, b5)
Dim p6 As New PointF(a6, b6)
Dim p7 As New PointF(a7, b7)
Dim p8 As New PointF(a8, b8)
Dim p9 As New PointF(a9, b9)
Dim p10 As New PointF(a10, b10)
Dim pArray As PointF() = {p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10}
For i As Integer = 0 To pArray.Length - 1
e.Graphics.DrawCurve(bluePen, pArray)
e.Graphics.SmoothingMode = SmoothingMode.HighQuality
Next
'I tried to use nested loops but to no avail
'For a = 0 To 50 Step 5
' For b = 0 To 100 Step 10
' For p = 0 To 10 Step 1
' Next
' Next
'Next
End Sub
End Class