Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Storing a selected ListBox item into a String variable [modified]

Storing a selected ListBox item into a String variable [modified]

Scheduled Pinned Locked Moved Visual Basic
question
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    reegan41
    wrote on last edited by
    #1

    I want to be able to click on an item in a ListBox, then using the AfterUpdate() Sub-routine, be able to store that value into a String variable. My loop is as follows: ***START*** Dim iterator As Long Dim descriptionString As String For iterator = 0 to Descriptions_lst.ListCount - 1 If Descriptions_lst.Selected(iterator) Then descriptionName = Descriptions_lst.Column(0, iterator) End if Next iterator ***END*** I'm not exactly sure what the 'Column' does, but apparently this is supposed to get the string value from the selected ListBox item. However, it is not working. I just get empty values for my descriptionName variable. Any ideas? -- modified at 10:04 Thursday 14th June, 2007

    G 1 Reply Last reply
    0
    • R reegan41

      I want to be able to click on an item in a ListBox, then using the AfterUpdate() Sub-routine, be able to store that value into a String variable. My loop is as follows: ***START*** Dim iterator As Long Dim descriptionString As String For iterator = 0 to Descriptions_lst.ListCount - 1 If Descriptions_lst.Selected(iterator) Then descriptionName = Descriptions_lst.Column(0, iterator) End if Next iterator ***END*** I'm not exactly sure what the 'Column' does, but apparently this is supposed to get the string value from the selected ListBox item. However, it is not working. I just get empty values for my descriptionName variable. Any ideas? -- modified at 10:04 Thursday 14th June, 2007

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      I only find the ListCount and Selected properties in the Office classes. Is this VBA?

      --- single minded; short sighted; long gone;

      R 1 Reply Last reply
      0
      • G Guffa

        I only find the ListCount and Selected properties in the Office classes. Is this VBA?

        --- single minded; short sighted; long gone;

        R Offline
        R Offline
        reegan41
        wrote on last edited by
        #3

        Ya, its VBA using Access. I need to somehow verify that 'if' statement properly, then get the selected item into a String variable.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups