I need help with the extra credit part Instructions Write a Visual Basic program
ID: 3727239 • Letter: I
Question
I need help with the extra credit part Instructions Write a Visual Basic program using Visual Studio 2015. Do not develop this program using any other IDE or programming language. The program will meet the following system requirements: The user will start by typing in a positive integer o! Check to make sure that the user inputted a positive integer X, into the textbox. If it is not a positive integer, the following instructions will execute: i. Display in a MessageBox: "Invalid Input ii. Clear the contents of the textbox iii. Place the Focus back into the textbox If X is a positive integer, simulate the picturebox moving from right to left X many times. For 10 extra credit points (towards this exam), have your program suspend (pause) for exactly 1 millisecond after each time that the picturebox moves 10 pixels to the left. This will slow down the speed at which the picturebox moves 1. Position the picturebox back to the right hand side of the form. Clear the Contents of the textbox 2. 3. into When the user clicks on the Exit button, the will close The program must look like the following application: Move Image Please enter the number of iterations 2 Gol ReselExplanation / Answer
you can use Threading.Thread.Sleep(1) function to make tha application wait for 1 milisecond. you can pass any value to Threading.Thread.Sleep(1) as parameter instead of 1.
Code:
MoveImage.vb:
Public Class MoveImage
Dim point As Point
Private Sub btnGo_Click(sender As Object, e As EventArgs) Handles btnGo.Click 'button go click event
Dim number As Int32 = Int32.Parse(txtValue.Text)
Dim i As Integer = 0
If number <= 0 Then 'checks if number is negative
MessageBox.Show("Invalid Input") 'displays the message box
txtValue.Text = "" 'set the textbox value to null
txtValue.Focus() 'sets the focus to textbox
PictureBox1.Location = point 'set image to its initial point
Else
While i < number 'execute moving process as many times as entered in textbox
While PictureBox1.Location.X < Me.Right - 150 'checks if the image is alligned to right
PictureBox1.Location = New Point(PictureBox1.Location.X + 10, PictureBox1.Location.Y) 'moves the picture to left by 10 pixels
Threading.Thread.Sleep(1) 'makes the thread sleep of 1 milisecond. it will make application wait for 1 second
End While
PictureBox1.Location = New Point(point.X, point.Y) 'setting picturebox to starting point
i = i + 1
End While
End If
End Sub
Private Sub MoveImage_Load(sender As Object, e As EventArgs) Handles MyBase.Load 'page load event
point = PictureBox1.Location 'setting coordinate starting point of picturebox
End Sub
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click 'button exit event
Application.Exit() 'exiting the application
End Sub
Private Sub btnReset_Click(sender As Object, e As EventArgs) Handles btnReset.Click 'button reset event
txtValue.Text = "" 'set the textbox value to null
PictureBox1.Location = point 'set image to its initial point
End Sub
End Class
Components:
PictureBox1 - picture box used in the form to move.
txtValue - text box used in the form to enter the value
btnExit - button to exit the application
btnReset - button to reset all values to initial
btnGo - button to move that image