randomizing names

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • richy176
    New Member
    • May 2007
    • 8

    randomizing names

    hey. i was wondering if there is a way to randomize a list of names?

    i have a listbox name list1 and i want the list to shuffle a list of names, 18 names in total.

    if there is any way i can do this please help me on this. much appreaciated!
  • Atran
    Contributor
    • May 2007
    • 319

    #2
    Originally posted by richy176
    hey. i was wondering if there is a way to randomize a list of names?

    i have a listbox name list1 and i want the list to shuffle a list of names, 18 names in total.

    if there is any way i can do this please help me on this. much appreaciated!
    Hello, I try many ways to do that, but I dont find anyway, and I confused.
    But try this code:
    Code:
    Imports System
    Imports System.Windows.Forms
    
    Public Class Form1
    
        Dim x As New ListBox()
        Dim z As New Button()
        Dim s As String() = New String() {"VB", "C#", "C++"}
        Dim random As New Random()
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            '-------------------------
            x.Location = New Point(12, 12)
            Controls.Add(x)
            '--------------
            z.Location = New Point(12, 200)
            z.Text = "Click here"
            AddHandler z.Click, AddressOf z_Click
            Controls.Add(z)
        End Sub
    
        Private Sub z_Click(ByVal sender As Object, ByVal e As EventArgs)
            x.Items.Add(s(random.[Next](0, 3)))
        End Sub
    
    End Class
    Hope this help you.

    Comment

    • richy176
      New Member
      • May 2007
      • 8

      #3
      hey, thanks for replying. i belive i forgotten to give a better detail.

      im using visual basic 6.0, and when i input names which i know how to do it, i want to click on a command button to shuffle the names.

      i hope thats given u a better idea as to what to do


      Originally posted by Atran
      Hello, I try many ways to do that, but I dont find anyway, and I confused.
      But try this code:
      Code:
      Imports System
      Imports System.Windows.Forms
      
      Public Class Form1
      
          Dim x As New ListBox()
          Dim z As New Button()
          Dim s As String() = New String() {"VB", "C#", "C++"}
          Dim random As New Random()
      
          Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
              '-------------------------
              x.Location = New Point(12, 12)
              Controls.Add(x)
              '--------------
              z.Location = New Point(12, 200)
              z.Text = "Click here"
              AddHandler z.Click, AddressOf z_Click
              Controls.Add(z)
          End Sub
      
          Private Sub z_Click(ByVal sender As Object, ByVal e As EventArgs)
              x.Items.Add(s(random.[Next](0, 3)))
          End Sub
      
      End Class
      Hope this help you.

      Comment

      Working...