Imports System.IO Imports System.Threading Public Class Form1 Private p2vbW As Integer Private p2vbH As Integer Private p2vbX1 As Integer Private p2vbY1 As Integer Private p2vbX2 As Integer Private p2vbY2 As Integer Private myPen As Pen Private formGraphics As System.Drawing.Graphics Private myBrush As System.Drawing.SolidBrush Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim winWidth As Integer winWidth = 300 Dim winHeight As Integer winHeight = 300 Dim win As Integer Text = "Back and Forth" Width = winWidth + 100 p2vbW = winWidth Height = winHeight + 100 p2vbH = winHeight p2vbX1 = 0 p2vbY1 = 0 p2vbX2 = winWidth p2vbY2 = winHeight ' make right side up coordinates! Dim rect As Rectangle rect = New Rectangle(New Point(200, 90), New Point(220, 100)) myPen = New Pen(Drawing.Color.Black, 1) formGraphics = CreateGraphics() formGraphics.DrawRectangle(myPen, rect) myBrush = New System.Drawing.SolidBrush(System.Drawing.Color.Blue) formGraphics.FillRectangle(myBrush, New Rectangle(200, 90, 220, 100)) Dim head As RectangleF myPen = New Pen(Drawing.Color.Black, 1) head.X = 40 head.Y = 100 head.Width = 25 head.Height = 25 formGraphics.DrawEllipse(myPen, head) myBrush = New System.Drawing.SolidBrush(System.Drawing.Color.Yellow) formGraphics.FillEllipse(myBrush, head) Dim eye1 As RectangleF myPen = New Pen(Drawing.Color.Black, 1) eye1.X = 30 eye1.Y = 105 eye1.Width = 5 eye1.Height = 5 formGraphics.DrawEllipse(myPen, eye1) myBrush = New System.Drawing.SolidBrush(System.Drawing.Color.Blue) formGraphics.FillEllipse(myBrush, eye1) Dim eye2 As Integer myPen = New Pen(Drawing.Color.Black, 3) formGraphics.DrawLine(myPen, 45, 105, 55, 105) Dim mouth As RectangleF mouth = New RectangleF(New Point(30, 90), New SizeF(50, 85)) myPen = New Pen(Drawing.Color.Black, 1) formGraphics.DrawEllipse(myPen, mouth) myBrush = New System.Drawing.SolidBrush(System.Drawing.Color.Red) formGraphics.FillEllipse(myBrush, mouth) Dim faceList As Object faceList = {head, eye1, eye2, mouth} Dim cir2 As RectangleF myPen = New Pen(Drawing.Color.Black, 1) cir2.X = 150 cir2.Y = 125 cir2.Width = 25 cir2.Height = 25 formGraphics.DrawEllipse(myPen, cir2) myBrush = New System.Drawing.SolidBrush(System.Drawing.Color.Red) formGraphics.FillEllipse(myBrush, cir2) moveAllOnLine(faceList, 5, 0, 46, 0.05) moveAllOnLine(faceList, -5, 0, 46, 0.05) Dim Control1 As New Label Control1.Left = p2vbW * ((winWidth / 2) / (p2vbX2 - p2vbX1)) Control1.Top = p2vbH - (p2vbH * ((20) / (p2vbY2 - p2vbY1))) Control1.Text = "Click anywhere to quit." Control1.AutoSize = True Controls.Add(Control1) End Sub Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load ''main() End Sub Public Sub moveAll(shapeList As Object, dx As Object, dy As Object) ' Move all shapes in shapeList by (dx, dy). For shape = 0 To shapeList.Length - 1 ''PYTHON2VB ''error shapeList(shape).X = shapeList(shape).X + dx shapeList(shape).Y = shapeList(shape).Y + dy formGraphics.DrawEllipse(myPen, shape) myBrush = New System.Drawing.SolidBrush(System.Drawing.Color.Yellow) formGraphics.FillEllipse(myBrush, shape) Next End Sub Public Sub moveAllOnLine(shapeList As Object, dx As Integer, dy As Integer, repetitions As Integer, delay As Single) ' Animate the shapes in shapeList along a line. ' Move by (dx, dy) each time. ' Repeat the specified number of repetitions. ' Have the specified delay (in seconds) after each repeat. ' For i = 0 To repetitions - 1 moveAll(shapeList, dx, dy) Threading.Thread.Sleep(delay * 1000) Next End Sub End Class