Home All Groups Group Topic Archive Search About
Author
11 Aug 2006 10:12 AM
Laserson
Hi! How to create an application that can show strings in a random
order? I tried to create an array of string and then use Randomize()
method by all my strings were shown one by one...

Author
11 Aug 2006 10:40 AM
Cor Ligthert [MVP]
Laserson,

Why use a randomized order when you can set an index number in the register,
than you are as well able to give your tips in a good sequence?

I hope this helps,

Cor



Show quoteHide quote
"Laserson" <laser***@yandex.ru> schreef in bericht
news:OAEzt6SvGHA.1512@TK2MSFTNGP04.phx.gbl...
> Hi! How to create an application that can show strings in a random order?
> I tried to create an array of string and then use Randomize() method by
> all my strings were shown one by one...
Author
12 Aug 2006 12:39 PM
Lars Graeve
Hello,


small example. Hope, it helps you.


Public Class Form1

    Dim tips() As String
    Const NO_OF_TIPS As Int32 = 15


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

        ' Setup tips (may be loaded from file in future)
        ReDim tips(NO_OF_TIPS - 1)
        For tip As Int32 = 0 To NO_OF_TIPS - 1
            tips(tip) = "Tip no. " & tip.ToString
        Next tip

        Randomize()

    End Sub


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

        'Show a tip
        Dim randomTip As Int32 = CInt(Rnd() * NO_OF_TIPS)
        MsgBox(tips(randomTip))

    End Sub

End Class


Greetings, Lars


Show quoteHide quote
"Laserson" <laser***@yandex.ru> schrieb im Newsbeitrag
news:OAEzt6SvGHA.1512@TK2MSFTNGP04.phx.gbl...
> Hi! How to create an application that can show strings in a random order?
> I tried to create an array of string and then use Randomize() method by
> all my strings were shown one by one...