Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
VB.NET Help?
#2
lol the debugger doesn't have a mind of it's own, you can't give it choices based on no logical calculation.

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.
Reply


Messages In This Thread
VB.NET Help? - by BreShiE - 01-15-2012, 05:52 AM
RE: VB.NET Help? - by AceInfinity - 01-15-2012, 05:57 AM
RE: VB.NET Help? - by BreShiE - 01-15-2012, 06:00 AM
RE: VB.NET Help? - by AceInfinity - 01-15-2012, 06:01 AM
RE: VB.NET Help? - by BreShiE - 01-15-2012, 08:12 AM
RE: VB.NET Help? - by AceInfinity - 01-15-2012, 05:27 PM

Forum Jump:


Users browsing this thread: 4 Guest(s)