Hi all I have written an app that draws a line from a startpoint and an
endpoint based on values typed in two textboxes. I placed a airplane at the
beginning of the line and I want to use the timer call and a loop to move the
airplane along the line until it gets to the end in 2 second intervals. Here is what i have so far I am stuck on the loop I cannot figure out how to do it. Thanks in advance for any help.
endpoint based on values typed in two textboxes. I placed a airplane at the
beginning of the line and I want to use the timer call and a loop to move the
airplane along the line until it gets to the end in 2 second intervals. Here is what i have so far I am stuck on the loop I cannot figure out how to do it. Thanks in advance for any help.
VB.NET:
Public Sub
btndrawline_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Me.Refresh()
Dim g As Graphics = Me.CreateGraphics
Dim B2 As Image = Image.FromFile("C:\Documents and Settings\Justin\My Documents\Visual Studio\Projects\drawmission\drawmission\Resources\b2.gif") 'define text for gdi output
Dim TOtext As String = "Take Off" Dim LAtext As String = "Land" 'Define font Dim NewFont As New Font("Arial", 11, FontStyle.Bold, GraphicsUnit.Pixel)
'defines value holder for the takeoff and landing text boxes
Dim startvalue As New Integer
Dim endvalue As New Integer
'sets start and endpoint points
Dim startpoint As New Point Dim endpoint As New Point
'sets point value for aircraft
Dim aircraft As New Point
'Defines all the points holders
Dim point1 As New Point
Dim point2 As New Point
Dim point3 As New Point
Dim point4 As New Point
Dim point5 As New Point
Dim point6 As New Point
Dim point7 As New Point
Dim point8 As New Point
Dim point9 As New Point
Dim point10 As New Point
Dim point11 As New Point
Dim point12 As New Point
Dim point13 As New Point
Dim point14 As New Point
Dim point15 As New Point
Dim point16 As New Point
Dim point17 As New Point
Dim point18 As New Point
Dim point19 As New Point
Dim point20 As New Point
Dim point21 As New Point
Dim point22 As New Point
Dim point23 As New Point
Dim point24 As New Point
'Clears previous data and redraws new line
Me.Refresh()
'set takeoff and landing text box to a value for the line
startvalue = Me.takeofftime.Text
endvalue = Me.LandTime.Text
'Define All start Point Ints
point12.X = 10
point12.Y = 100
point13.X = 40
point13.Y = 100
point14.X = 70
point14.Y = 100
point15.X = 100
point15.Y = 100
point16.X = 130
point16.Y = 100
point17.X = 160
point17.Y = 100
point18.X = 190
point18.Y = 100
point19.X = 220
point19.Y = 100
point20.X = 250
point20.Y = 100
point21.X = 280
point21.Y = 100
point22.X = 310
point22.Y = 100
point23.X = 340
point23.Y = 100
point24.X = 370
point24.Y = 100
point1.X = 400
point1.Y = 100
point2.X = 430
point2.Y = 100
point3.X = 460
point3.Y = 100
point4.X = 490
point4.Y = 100
point5.X = 520
point5.Y = 100
point6.X = 550
point6.Y = 100
point7.X = 580
point7.Y = 100
point8.X = 610
point8.Y = 100
point9.X = 640
point9.Y = 100
point10.X = 670
point10.Y = 100
point11.X = 700
point11.Y = 100
'assign values to startpoint
Select Case startvalue
Case 1200 To 1259
startpoint = point12
Case 1300 To 1359
startpoint = point13
Case 1400 To 1459
startpoint = point14
Case 1500 To 1559
startpoint = point15
Case 1600 To 1659
startpoint = point16
Case 1700 To 1759
startpoint = point17
Case 1800 To 1859
startpoint = point18
Case 1900 To 1959
startpoint = point19
Case 2000 To 2059
startpoint = point20
Case 2100 To 2159
startpoint = point21
Case 2200 To 2259
startpoint = point22
Case 2300 To 2359
startpoint = point23
Case 0 To 59
startpoint = point24
Case 100 To 159
startpoint = point1
Case 200 To 259
startpoint = point2
Case 300 To 359
startpoint = point3
Case 400 To 459
startpoint = point4
Case 500 To 559
startpoint = point5
Case 600 To 659
startpoint = point6
Case 700 To 759
startpoint = point7
Case 800 To 859
startpoint = point8
Case 900 To 959
startpoint = point9
Case 1000 To 1059
startpoint = point10
Case 1100 To 1159
startpoint = point11
End Select
'Assigns value to endpoint
Select Case endvalue
Case 1200 To 1259
endpoint = point12
Case 1300 To 1359
endpoint = point13
Case 1400 To 1459
endpoint = point14
Case 1500 To 1559
endpoint = point15
Case 1600 To 1659
endpoint = point16
Case 1700 To 1759
endpoint = point17
Case 1800 To 1859
endpoint = point18
Case 1900 To 1959
endpoint = point19
Case 2000 To 2059
endpoint = point20
Case 2100 To 2159
endpoint = point21
Case 2200 To 2259
endpoint = point22
Case 2300 To 2359
endpoint = point23
Case 0 To 59
endpoint = point24
Case 100 To 159
endpoint = point1
Case 200 To 259
endpoint = point2
Case 300 To 359
endpoint = point3
Case 400 To 459
endpoint = point4
Case 500 To 559
endpoint = point5
Case 600 To 659
endpoint = point6
Case 700 To 759
endpoint = point7
Case 800 To 859
endpoint = point8
Case 900 To 959
endpoint = point9
Case 1000 To 1059
endpoint = point10
Case 1100 To 1159
endpoint = point11
End Select
'Draw box for flight graphic
g.DrawRectangle(New Pen(Color.Black, 5), 8, 70, 345, 90)
g.FillRectangle(Brushes.White, 8, 70, 345, 90)
'Draws line for takeoff to landing
g.DrawLine(New Pen(Color.Blue, 3), startpoint, endpoint)
'Draw Start and end lines
g.DrawLine(New Pen(Color.Black, 1), startpoint, (startpoint - New Point(0, 10)))
g.DrawLine(New Pen(Color.Black, 1), endpoint, (endpoint - New Point(0, 10)))
'Add Text To the plot
g.DrawString(TOtext, NewFont, Brushes.Black, startpoint - (New Point(0, 15)))
g.DrawString(LAtext, NewFont, Brushes.Black, endpoint - (New Point(30, 15)))
'Move Aircraft along the line every 2 seconds g.DrawImage(B2, startpoint - New Point(0, -5))
Last edited: