Tip of The Day

  • Thread starter Thread starter Laserson
  • Start date Start date
L

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...
 
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
 
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
 
Back
Top