01-15-2012, 05:57 AM
(This post was last modified: 01-15-2012, 05:59 AM by AceInfinity.)
lol the debugger doesn't have a mind of it's own, you can't give it choices based on no logical calculation.
that's what I would do.
My function ReturnKey takes 2 parameters, first parameter specifies the input string array, which i've created above called KeyA(), and the second parameter is used to identify the last index of that array so that our random calculation doesn't try to specify or return an index out of the array.
Code:
Public KeyA() As String = {"item 1", "item 2", "item 3", "item 4", "item 5"}
Private Shared Function ReturnKey(ByVal InputArray() As String, ByVal LastKeyIndex As Integer)
Dim Key As New Random
Return InputArray(Key.Next(0, LastKeyIndex))
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Textbox1.Text = ReturnKey(KeyA, 4)
End Sub
that's what I would do.
My function ReturnKey takes 2 parameters, first parameter specifies the input string array, which i've created above called KeyA(), and the second parameter is used to identify the last index of that array so that our random calculation doesn't try to specify or return an index out of the array.