Results 1 to 2 of 2

Thread: click list box

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 1999
    Posts
    20

    Post

    ok. i got a thing where it pick a random number. now i need it to click the number in the list box. say like there a list box. it there 5 items in it. well it will pick a random number from1 to 5. it if 4 it will clikc the 4 item in the list box how do i do this.


    thanks for your help.

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    Use the Random Number to set the Listboxes ListIndex Property, eg.
    Code:
    Private Sub Command1_Click()
        Randomize Timer
        List1.ListIndex = Int(Rnd * 19)
    End Sub
    
    Private Sub Form_Load()
        Dim iIndex As Integer
        For iIndex = 1 To 20
            List1.AddItem "Item " & iIndex
        Next
    End Sub
    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width