Results 1 to 6 of 6

Thread: Problem with listbox

  1. #1

    Thread Starter
    Hyperactive Member Matt-D's Avatar
    Join Date
    Nov 1999
    Location
    Mettmann, Germany
    Posts
    305

    Question

    I use a random to select one item in a listbox. Then I
    access a database with this item. But this (database access)
    only works, when I press a button (like space) or click on
    the item again. Is there a function so that I don't need to click on it again ?

    Is there a function which works like clicking on an
    item in a listbox ???



    Code:
    ''''''My random, 'L1 = Listbox
        A = L1.ListCount
        Randomize
        MyRand = Int(A * Rnd)
        L1.ListIndex = MyRand
        L1.SetFocus
    [i] !! VB 3.0 !! Matt-D(eutschland)

    [Edited by Matt-D on 11-03-2000 at 12:16 PM]

  2. #2
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    hmmm.. don't really get your problem, but if nothing else helps try SendKeys "{space}"
    but this is a real crappy way so try to explain your prob better so we'll can help you better
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  3. #3
    Junior Member
    Join Date
    Aug 2000
    Location
    Girona
    Posts
    18
    You can call the method you use to acces the database, for example:

    ''''''My random, 'L1 = Listbox
    A = L1.ListCount
    Randomize
    MyRand = Int(A * Rnd)
    L1.ListIndex = MyRand
    L1.SetFocus
    call L1_LostFocus 'or the event when you acces to database



  4. #4
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606
    I think that's the problem:

    List1.Selected(MyRand) = True

    Instead of

    L1.ListIndex = MyRand


  5. #5
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Is there a function which works like clicking on an
    item in a listbox ???


    You could always do
    Call List1_Click()
    but if you really want to click you need the api...
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  6. #6

    Thread Starter
    Hyperactive Member Matt-D's Avatar
    Join Date
    Nov 1999
    Location
    Mettmann, Germany
    Posts
    305
    [b] Problem Solved


    I forgot come code - doh
    : INP2.Text = L1

    But thanks

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