Randomize()
lblassign2.Text = Int((10 - 1 + 1) * Rnd() + 1)
How can I change this so It will generate one of 4 words. The words are Hearts, Clubs, Spades and Diamonds
Also these four words should be capitalized.
Randomize()
lblassign2.Text = Int((10 - 1 + 1) * Rnd() + 1)
How can I change this so It will generate one of 4 words. The words are Hearts, Clubs, Spades and Diamonds
Also these four words should be capitalized.
randomly generate one of four words
Toutouni
trying to put an integer into a string value would be one problem....
lblassign1.Text = Cstr(Int((10 - 1 + 1) * Rnd() + 1))
sanwanas
Randomize()
Dim UpperBound As Integer = 3 Dim LowerBound As Integer = 0 Dim value As Integer = CInt(Int((UpperBound - LowerBound + 1) * Rnd() + LowerBound))lblsuit1.Text = Suit(value)
'2nd suit Dim Suit2() As String = New String() {"Hearts", "Spades", "Clubs", "Diamonds"}Randomize()
Dim UpperBound2 As Integer = 3 Dim LowerBound2 As Integer = 0 Dim value2 As Integer = CInt(Int((UpperBound - LowerBound + 1) * Rnd() + LowerBound))lblsuit2.Text = Suit2(value)
How can I make it to were it will never generate the same word twice, I never want lblsuit1.text to be the same as lblsuit2.text
rogupta
Ash Dude
I have another question, I keep getting an error when I use this code, what am I doing wrong
Randomize()
lblassign1.Text = Int((10 - 1 + 1) * Rnd() + 1)
ChinaTiger
You sequence will not be a random sequence if you don't want the same choice twice because that is a property of independently generated numbers.
There are lots of ways to go about this. One is to save the last choice and if the last choice is the same as the current random choice - do the ramdomization agin until the randomized choice is not the same as the last choice.
AArben
RSUser08
Dim
Suit() As String = New String() {"Hearts", "Spades", "Clubs", "Diamonds"} Randomize() Dim UpperBound As Integer = 3 Dim LowerBound As Integer = 0 Dim value As Integer = CInt(Int((UpperBound - LowerBound + 1) * Rnd() + LowerBound)) MessageBox.Show(Suit(value))