Results 1 to 8 of 8

Thread: Listbox syntax?

  1. #1

    Thread Starter
    Addicted Member tonyenkiducx's Avatar
    Join Date
    Oct 2000
    Location
    London England
    Posts
    147
    Anyone know the syntax for calling a click on an item in a list box... IE I have 3 names in a listbox, I click on one of em, and I want it to open another form, and pass the info from that list item to the new form.

  2. #2
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    In form1:
    Code:
    Dim X As Integer
    Private Sub Form_Load()
    For X = 0 To 15
    List1.AddItem X
    Next X
    End Sub
    
    
    
    Private Sub List1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
        Form2.Info = List1.Text
        Form2.Show
    End Sub
    In form2:

    Code:
    Option Explicit
    Public Info As String
    
    Private Sub Form_Load()
    MsgBox Info
    End Sub
    Hope that helped!
    Jop - validweb.nl

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

  3. #3
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Use the click event of the listbox
    '
    Form2.Show
    Form2.Text1.text = Form1.List1.Text
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  4. #4
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Jop
    A friendly word of advice... you should never use Public varaiables unless there is no other way around things.....and that according to Microsoft

    Later:
    Wayne
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  5. #5
    Guest
    If you right click the listbox, you get a menu box. by selecting "View Code" you will get (at least I get) a new subroutine.

    Private Sub boxname_click()

    You put your code in here. Whenever anything in boxname is selected (I assume this is a single select, I don't know what happens in multi-select) the mouse click event is fired.

    At least, that's the way it ACTS.


    Good Luck
    DerFarm

  6. #6
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    HeSaidJoe, I have to use a public variable right? how do I pass the info the variable then?? yeah you're right, I can pass it to a textbox first hehe that's better, but doesn't the textbox takes up memory then?
    Jop - validweb.nl

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

  7. #7
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Why don't you use public variables in a standard module, then the form2 will read from the module
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  8. #8
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Job, you are right...I should wear my glasses..I thought he was posting the information into a textbox.
    Being as he has to pass it to something, if it's a control, use the control (textbox or whatever) and if a var then it should be a public var in a module.

    My error! Sorry...I guess this is a time for a public var.

    Wayne
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

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