Advertisement
Flakeytechbison

Untitled

Aug 6th, 2020
736
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Public Class Form1
  2.     Private Sub btnGo_Click(sender As Object, e As EventArgs) Handles btnGo.Click
  3.         'Declarations
  4.        Dim intRandomArray(5) As Integer
  5.         Dim i As Integer
  6.         Dim intLargest As Integer
  7.         Dim intSmallest As Integer
  8.         'these values are for the if loop to check for largest and smallest
  9.        intLargest = 0
  10.         intSmallest = 100
  11.         'this is to help the random numbers be random when the program runs
  12.        Randomize()
  13.         'this is the loop to fill the array with random numbers
  14.        For i = 0 To 5
  15.             intRandomArray(i) = Int(Rnd() * 100 + 1)
  16.             'This if statements below are to check for the larget number and smallest within the array
  17.            If intRandomArray(i) > intLargest Then
  18.                 intLargest = intRandomArray(i)
  19.             End If
  20.             If intRandomArray(i) < intSmallest Then
  21.                 intSmallest = intRandomArray(i)
  22.             End If
  23.         Next i
  24.         'Output for the random numbers and also the largest and smallest numbers in the array
  25.        lblNumber1.Text = intRandomArray(0).ToString
  26.         lblNumber2.Text = intRandomArray(1).ToString
  27.         lblNumber3.Text = intRandomArray(2).ToString
  28.         lblNumber4.Text = intRandomArray(3).ToString
  29.         lblNumber5.Text = intRandomArray(4).ToString
  30.         lblNumber6.Text = intRandomArray(5).ToString
  31.         lblLargestResult.Text = intLargest.ToString
  32.         lblSmallestResult.Text = intSmallest.ToString
  33.     End Sub
  34. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement