Listbox Items

*Warning: More then likley a dumb newbie question, take note. You HAVE been warned.*

Allright, How do I make seperate, reactions, for each item you click in a listbox. Exp. Lets say you have a list of a few things:

Dog
Cat
Horse

That was your list in the listbox. How would I make it so each animal you click on puts some text into a textbox? so if you click on dog it loads some text that says 'a dog is mans best friend'?



Comments

  • : *Warning: More then likley a dumb newbie question, take note. You HAVE been warned.*
    :
    : Allright, How do I make seperate, reactions, for each item you click in a listbox. Exp. Lets say you have a list of a few things:
    :
    : Dog
    : Cat
    : Horse
    :
    : That was your list in the listbox. How would I make it so each animal you click on puts some text into a textbox? so if you click on dog it loads some text that says 'a dog is mans best friend'?
    :
    Private Sub Form_Load()

    List1.AddItem "Dog", 0
    List1.AddItem "Cat", 1
    List1.AddItem "Horse", 2

    End Sub

    Private Sub List1_Click()

    Static Animals(0 To 2) 'increase this the more things you have
    Animals(0) = "is a mans best friend"
    Animals(1) = "is a an ignorant creature"
    Animals(2) = "cant be forced to drink when taken to water"


    MsgBox Animals(List1.ListIndex)

    'or you could make this a text box

    End Sub

    hope that helps

    Lee



  • Thanks seems to be going on the right idea, But I need a little bit more. Now how do I take the text for each item, and stick it in a textbox?

    I tried this idea...

    Animals(0).Text1 = "Mans best friend"

    But didnt work. Thanks for the help so far, Additional would be very appretiated!

  • Allright sorry, I missed the little piece at the end of your post. I can get a MsgBox to pop up but I cant get the text to go in a TextBox...heres what ive tried:

    TextBox Animals(List1.ListIndex)
    TextBox.Text1 Animals(List1.ListIndex)
    TextBox.Text1 = Animals(List1.ListIndex)

    None work.

  • Allright sorry, I missed the little piece at the end of your post. I can get a MsgBox to pop up but I cant get the text to go in a TextBox...heres what ive tried:

    TextBox Animals(List1.ListIndex)
    TextBox.Text1 Animals(List1.ListIndex)
    TextBox.Text1 = Animals(List1.ListIndex)

    None work.

    Allright nevermind I figured it out....
    Text1.Text = blah blah

    Ya. Allright last little prob Im having is how do I make I think the term is courier return. If the sentence is too long and it runs off the TextBox, how do i format it? Also change colors, Bold...things like that?

  • Hi Try changing the Text box multiline propertie to 'True'
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories