array random order

zoveelstebiker

New member
Joined
Nov 11, 2007
Messages
3
Programming Experience
Beginner
I need to create an array of random values, with values between 1 and 26.All values have to be used,but there should be no duplicates

example the first time the code should give this : (3,7,8,23,11,4,21,...)

and the next time te form loads : (3,5,8,9,22,11,26,1,4,18,....)

So an array that contains all integer Values between 1 and 26 , with no duplicates.

then i want to use this values as index for a array with money ammounts so that every time my amounts are at a "different" place.This is for a "deal or no deal game".

my try is :
VB.NET:
     For i = 0 To 25
            will = willekeurig.Next(i, 26)
            hulp = bedragen(i)
            bedragen(i) = bedragen(will)
            bedragen(will) = hulp
            Label3.Text = will

        Next i

this code selects a random element of my array with amounts but how do i repeat this or store it in a new array ? im a complete newbie at vb.net and any help is gratefully accepted ! i know that there is a old topic about a deal or no deal game but i can't figure it out with that example.

regards !
 
Last edited:
This code does select a random number between 0 and 26 ,and the values seem to be unique , but how do i store them in a new array ? now i've got all the values in the messagebox ?

thanx in advance ! (And sorry i'm such a newbie)
 
If you look @ J's code there, all of the values are being stored in an array (ArrayList, to be more precise)

VB.NET:
  Dim list As New ArrayList   'Declares the list/array
  For i As Integer = 1 To 10 
    list.Add(i)                     'Puts the current element i, in the "list" variable
  Next i

So, @ the end of that code, you have the variable called "list" containing the numbers 1 to 10. You could put a watch on the variable in the IDE or view the contents through the immediate window.

J's code then accesses these elements putting them in the message box, which is what your seeing displayed.
 
If you look @ J's code there, all of the values are being stored in an array (ArrayList, to be more precise)

VB.NET:
  Dim list As New ArrayList   'Declares the list/array
  For i As Integer = 1 To 10 
    list.Add(i)                     'Puts the current element i, in the "list" variable
  Next i

So, @ the end of that code, you have the variable called "list" containing the numbers 1 to 10. You could put a watch on the variable in the IDE or view the contents through the immediate window.
J's code then accesses these elements putting them in the message box, which is what your seeing displayed.

And what do you mean with IDE and the red text ? maybe my english isn't to bad to understand that.

I get that , but when I use :

VB.NET:
label1.text=list(0)

there is an indexoutofrange error ? Or can't i acces an arraylist like this ?

thx in advance !
 
Back
Top