Results 1 to 5 of 5

Thread: populate a combobox

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2004
    Location
    in the heart of the Mediterranean
    Posts
    1,143

    populate a combobox

    Hi,

    Im trying to populate a combo first time coding but no luck. Any ideas how its done. Below is my code. Thanks


    Private Sub cmb_Change()
    cmb.ListIndex = 0
    cmb.AddItem ("Yellow")
    cmb.AddItem ("Pink")
    cmb.AddItem ("Blue")
    cmb.ListIndex = -1
    End Sub

  2. #2
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: populate a combobox

    You shouldn't add the items in the change event of the combo box, you should do it in the form load event. The change event is fired when you type something in the textbox part of the combo box.


    Has someone helped you? Then you can Rate their helpful post.

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: populate a combobox

    Which Office program is this in? Is it in a UserForm or ???

    If a UserForm then you could use the Initialize event of the Form to load all the combo's items.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2004
    Location
    in the heart of the Mediterranean
    Posts
    1,143

    Re: populate a combobox

    I am putting the control in a PowerPoint slide and I dont know the object to call and which method on slide load. Can you help please

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2004
    Location
    in the heart of the Mediterranean
    Posts
    1,143

    Re: populate a combobox

    bump

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