I know the basics of arrays and graphics (plotting of graphs, creating trigonometric functions) in NET Framework.
I cannot seem to visualize how I can manage to generate array elements randomly, represented by the bar heights (in white), just like in the image below:
I have only tried the code below and I only get a single number every time I generate a number. What I am expecting is to have 0 to 100 listed in a random order but I cannot do it.
Public Class FormSortingAlgorithm
Dim rnd As New Random()
Dim nums() As Integer
Dim i As Integer
Private Sub btnGenerate_Click(sender As Object, e As EventArgs) Handles btnGenerate.Click
Dim i As Integer
ReDim nums(19)
For i = 0 To 19
nums(i) = rnd.Next(0, 100)
Next
End Sub
Private Sub btnDisplayArray_Click(sender As Object, e As EventArgs) Handles btnDisplayArray.Click
txtDisplay.Text = nums(j) & nums(i)
End Sub
End Class
CodePudding user response:
Note: Assuming Windows Forms, given the names used in the question
- This line:
txtDisplay.Text = nums(j) & nums(i)
won't show the content of your array in a TextBox, just a single glued up number, composed by two elements in the array.
In casej
is defined somewhere and it represents a valid index
You can useCodePudding user response:
---<<>><<<IMGTART'WRITE'>>> AWM Special call fowler as mobieba Public Class FormSortingAlgorithm Dim rnd As New Random() Dim nums() As Integer Dim i As Integer Private Sub btnGenerate_Click(sender As Object, e As EventArgs) Handles btnGenerate.Click Dim i As Integer ReDim nums(19) For i = 0 To 19 nums(i) = rnd.Next(0, 100) Next End Sub Private Sub btnDisplayArray_Click(sender As Object, e As EventArgs) Handles btnDisplayArray.Click txtDisplay.Text = nums(j) & nums(i) End Sub End Class END class hit bot and run Dns Vitett Customm Off. With Call OUT To my ATACKOVERFLOW