+ Reply to Thread
Results 1 to 5 of 5

How to select a default item in the VB ListBox?

  1. #1
    Registered User
    Join Date
    03-15-2010
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    6

    How to select a default item in the VB ListBox?

    This is VB related.

    If I have a ListBox in VB, and it is populated with values "Mon", "Tues", "Wed".

    How do I make it so that it will will select, for example, "Tues" if I click on a button?

    is it like:
    ListBox1.selected("Tues") or something similar?

    thanks.

  2. #2
    Registered User
    Join Date
    03-21-2010
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: How to select a default item in the VB ListBox?

    I have created some forms and use the following when opening the form:


    Private Sub UserForm_Initialize()
    'Sets up the fields when the form is first opened

    txtListBox1 = "Tues"

    End Sub


    Are you using forms?

  3. #3
    Registered User
    Join Date
    03-15-2010
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: How to select a default item in the VB ListBox?

    Hi kym1901,

    Yes, I'm using forms.

    I tried txtListBox1 = "Tues"

    but it didn't work.

    Are you sure it's not something like

    ListBox1.setValue("Tues")?

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How to select a default item in the VB ListBox?

    Maybe:
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  5. #5
    Registered User
    Join Date
    03-21-2010
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: How to select a default item in the VB ListBox?

    Sorry, I fogot the .text
    Please Login or Register  to view this content.
    Cheers.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1