Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class Form1
- Private Sub btnGo_Click(sender As Object, e As EventArgs) Handles btnGo.Click
- 'Declarations
- Dim intRandomArray(5) As Integer
- Dim i As Integer
- Dim intLargest As Integer
- Dim intSmallest As Integer
- 'these values are for the if loop to check for largest and smallest
- intLargest = 0
- intSmallest = 100
- 'this is to help the random numbers be random when the program runs
- Randomize()
- 'this is the loop to fill the array with random numbers
- For i = 0 To 5
- intRandomArray(i) = Int(Rnd() * 100 + 1)
- 'This if statements below are to check for the larget number and smallest within the array
- If intRandomArray(i) > intLargest Then
- intLargest = intRandomArray(i)
- End If
- If intRandomArray(i) < intSmallest Then
- intSmallest = intRandomArray(i)
- End If
- Next i
- 'Output for the random numbers and also the largest and smallest numbers in the array
- lblNumber1.Text = intRandomArray(0).ToString
- lblNumber2.Text = intRandomArray(1).ToString
- lblNumber3.Text = intRandomArray(2).ToString
- lblNumber4.Text = intRandomArray(3).ToString
- lblNumber5.Text = intRandomArray(4).ToString
- lblNumber6.Text = intRandomArray(5).ToString
- lblLargestResult.Text = intLargest.ToString
- lblSmallestResult.Text = intSmallest.ToString
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement