|
-
Apr 13th, 2007, 08:22 PM
#1
Thread Starter
Lively Member
[RESOLVED] Randomize from dynamic array
I have a dynamic array that will be populated by the user which are strings. I also have a textbox for the user to enter a number of random items to be pulled from the array and listed in a text box on another form when a button is clicked on main form. I'm not sure how to go about getting random strings from a user generated array. Here is the code for the user input. Any help for the btnrandom_click event would be appreciated.
Public Class frmMain
Dim bunkname() As String
Dim cells As Integer
Private Sub btnInput_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInput.Click
Dim prompt, title As String
Dim i As Short
prompt = "Enter each Bunk number."
cells = InputBox("How many total bunks do you have?", "Create array")
If cells > 0 Then ReDim bunkname(cells - 1)
For i = 0 To UBound(bunkname)
title = "Cells " & (i + 1)
bunkname(i) = InputBox(prompt, title)
Next
End Sub
Private Sub btnRandom_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRandom.Click
frmList.Show()
Randomize()
End Sub
End Class
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|