Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15711

VS Code [RESOLVED] Random function seems to only run once

$
0
0
Code:

    For x = 0 To 99
                dsnewrow = dsprov.Tables("Provinces").NewRow()
                dsnewrow.Item(1) = dsrulers.Tables(0).Rows(x).Item(0)
                dsnewrow.Item(2) = dsrulers.Tables(0).Rows(x).Item(1)
                Dim rnd As New Random
                Dim utgetrace As String = PlayerRaces(rnd.Next(0, 6))
                dsnewrow.Item(3) = utgetrace
                dsnewrow.Item(4) = "None"
                dsnewrow.Item(5) = 400
                dsnewrow.Item(6) = 400000
                dsnewrow.Item(7) = 0
                If utgetrace <> "Undead" Then
                    dsnewrow.Item(8) = 100000
                Else
                    dsnewrow.Item(8) = 0
                End If
                dsnewrow.Item(9) = 0
                dsnewrow.Item(10) = 0
                dsnewrow.Item(11) = 0
                dsnewrow.Item(12) = 1500
                dsnewrow.Item(13) = Now()
                dsnewrow.Item(14) = Now()
                dsprov.Tables("Provinces").Rows.Add(dsnewrow)
            Next

Code:

PlayerRaces(0) = "Human"
        PlayerRaces(1) = "Elf"
        PlayerRaces(2) = "Dwarf"
        PlayerRaces(3) = "Orc"
        PlayerRaces(4) = "Faery"
        PlayerRaces(5) = "Halfling"
        PlayerRaces(6) = "Avian"
        PlayerRaces(7) = "Undead"

This seems to work one time only. It will pick a selection once from the array and then copy that same selection 100 times. I would imagine that it'd at least attempt to be different through each iteration.

Viewing all articles
Browse latest Browse all 15711

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>