Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Nov 2004
    Location
    Perth, UK
    Posts
    105
    Thanks
    1
    Thanked 0 Times in 0 Posts

    VB6 Listbox Help

    NOT HOMEWORK - My friends don't know VB, so I am doing this for them.

    I have written a program that will pick a random name out of a listbox, because I need it for an activity I am involved in.

    However, I don't know how to actually display the name chosen from the list. All I get is the index number of that name.

    Example: "The winner is 3". I want that to be: "The winner is Sam."

    I have tried SelectedIndex, SelectedItem and so on. What am I doing wrong?
    Last edited by Geodesic_D; 08-25-2007 at 12:23 AM.
    Geodesic_D
    "I'd much rather be called GeodesicDragon."

  • #2
    Regular Coder
    Join Date
    Nov 2004
    Location
    Perth, UK
    Posts
    105
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I should also point out that the names are being added to said list box one at a time using a textbox and a command button.

    So I think it would have something to do with the fact I am not assigning index numbers to each name.
    Geodesic_D
    "I'd much rather be called GeodesicDragon."

  • #3
    Regular Coder
    Join Date
    Nov 2004
    Location
    Perth, UK
    Posts
    105
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Ahhh! It was so simple!

    I got it, never mind.
    Geodesic_D
    "I'd much rather be called GeodesicDragon."

  • #4
    New to the CF scene
    Join Date
    Dec 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    VB^ Listbox help

    edited out
    Last edited by SpencerGraevn; 12-23-2007 at 10:05 PM.

  • #5
    New to the CF scene
    Join Date
    Dec 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    VB6 Listbox help

    Hello!

    I'm working on an RSS Maker for podcasts, and it's been a while since school, so I've forgotten most of my VB6 training.

    I have two tables created in Access: "Channels," which contain ID, CTitle and ITitle; and "MasterList," which contains ID and MTitle.

    On my form, I have two ListBoxes called lst_channels, which contains the data from MTitle; and lst_items, which I would like to fill with the information from ITitle.

    MasterList/MTitle contains a list of Podcasts.
    Channels/ITitle contains a list of episodes.
    Channels/CTitle shows which Podcast an Episode belongs to.

    The following code allows lst_channels to accept the info from MTitle.
    Public Sub FillList()
    Dim SQL As String
    frm_MRPODCAST.lst_CHANNELS.Clear
    frm_MRPODCAST.lst_ID.Clear
    frm_MRPODCAST.lst_ITEMS.Clear
    frm_MRPODCAST.lst_SORTID.Clear

    SQL = "SELECT ID, MTitle FROM MasterList"
    RS.Open SQL, CN, adOpenStatic, adLockReadOnly
    If RS.RecordCount > 0 Then
    RS.MoveFirst
    End If
    While Not RS.EOF
    frm_MRPODCAST.lst_CHANNELS.AddItem RS.Fields("MTitle").Value
    frm_MRPODCAST.lst_ID.AddItem RS.Fields("ID").Value
    RS.MoveNext
    Wend
    RS.Close
    Set RS = Nothing
    End Sub

    Here's a picture of the interface:


    Now, I would like to be able to click on a Channel, such as "The Bridge," and have it display a list of all the episodes associated with that file. I wrote up a sub to do that, but I'm having... difficulty. Here's the code.

    Public Sub FillITEM()
    Dim SQL As String

    frm_MRPODCAST.lst_ITEMS.Clear
    frm_MRPODCAST.lst_SORTID.Clear

    SQL = "Select CTitle, ITitle FROM Channels where CTitle = " & lst_CHANNELS.List
    RS.Open SQL, CN, adOpenStatic, adLockOptimistic
    If RS.RecordCount > 0 Then
    RS.MoveFirst
    End If

    While Not RS.EOF
    frm_MRPODCAST.lst_ITEMS.AddItem RS.Fields("ITitle").Value
    frm_MRPODCAST.lst_SORTID.AddItem RS.Fields("CTitle").Value
    RS.MoveNext
    Wend
    RS.Close
    Set RS = Nothing
    End Sub


    When I click on something in the Channels Listbox, I get an "Arguement not optional" popup. When I delete the part that reads where CTitle = " & lst_CHANNELS.List, it simply displays every episode from every podcast. This is logical, since there are no qualifiers in the query, so what do I need to do in order to just pull up the episodes I want?

    Can anybody help? I remember this stuff being so much easier!!! A couple years of not working with a program will do that to ya, I suppose.


  •  

    Posting Permissions

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