如何在数组中排序并获得所需的数字

时间:2016-06-07 17:59:54

标签: vb.net

所以,正如标题所说,我需要能够对一组随机生成的数字进行排序,并让用户选择他们想要滚动的数字,比如他们想要掷4,他们将输入4 in一个文本框,在表格的某个地方会有一个标签,告诉用户该数字出现了多少次,我似乎无法弄明白,如何排序以及如何获得这个概率,任何帮助?

到目前为止,这是我的代码:

Public Class Chcked


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Public Sub cmdGenerate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdGenerate.Click
        ' Initialize the random-number generator.
        Dim strOutput As String

        Dim intArray(Val(txtFirst.Text)) As Integer
        Dim Counter As Integer
        Dim Random As Integer
        For Counter = 1 To Val(txtFirst.Text)

            Randomize()
            Random = Int(Rnd() * 6) + 1

            intArray(txtFirst.Text) = Random


            strOutput = intArray(txtFirst.Text)
            txtSequence.Text = " " & strOutput & " " + txtSequence.Text & " "

        Next Counter



    End Sub

    Private Sub Clear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Clear.Click
        txtSequence.Text = " "
    End Sub

    Private Sub Sort_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Sort.Click

    End Sub

End Class

0 个答案:

没有答案