mardi 29 décembre 2015

Issues With Ordering Array from Greatest To Least

Below you will see what I have for making a random array. I am needing to order the items from greatest to least and then be able to put them into textboxes according to the class the user has picked. This is for a DnD 4e ability generator. I need to be able to put the highest ability scores into the best suited field for that class.

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    'Dim randstr As New Random

    'Dim a As Integer
    'Dim b As Integer
    'Dim c As Integer
    'Dim d As Integer
    'Dim h As Integer
    'Dim f As Integer


    'a = randstr.Next(3, 18)
    'b = randstr.Next(3, 18)
    'c = randstr.Next(3, 18)
    'd = randstr.Next(3, 18)
    'h = randstr.Next(3, 18)
    'f = randstr.Next(3, 18)

    Static randomNumberGenerator As New System.Random


    Dim randomNumbers(6) As Integer ' Create the array

    Dim smallestNumber As Integer = 3 ' Set the lower bounds

    Dim largestNumber As Integer = 18 ' Set the upper bounds



    For i = 0 To 6 ' loop through each element in the array

        randomNumbers(i) = randomNumberGenerator.Next(smallestNumber, largestNumber)

    Next

    If CbClass.SelectedItem = "Fighter" Then

    End If
End Sub




Aucun commentaire:

Enregistrer un commentaire