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. Listbox problem

Listbox problem

Scheduled Pinned Locked Moved Visual Basic
helpquestion
4 Posts 3 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.
  • J Offline
    J Offline
    jaakinye
    wrote on last edited by
    #1

    I have listbox with the follwing data from the base: rownumber,a1,a2,a3,a4,a5,a6 1 1,2,3,6,5,4 2 3,2,9,5,7,5 3 4,5,2,8,9,7 4 9,9,8,2,3,5 5 9,8,5,1,2,4 6 7,3,6,8,4,9 etc,etc,etc I have 2 textbox textbox1 = the 3rd data in 2nd row textbox2 = the 5th data in 4th row How do I get these by code? can someone help? Tahnks :laugh:

    jaakinye

    L V 2 Replies Last reply
    0
    • J jaakinye

      I have listbox with the follwing data from the base: rownumber,a1,a2,a3,a4,a5,a6 1 1,2,3,6,5,4 2 3,2,9,5,7,5 3 4,5,2,8,9,7 4 9,9,8,2,3,5 5 9,8,5,1,2,4 6 7,3,6,8,4,9 etc,etc,etc I have 2 textbox textbox1 = the 3rd data in 2nd row textbox2 = the 5th data in 4th row How do I get these by code? can someone help? Tahnks :laugh:

      jaakinye

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Simplest way would be to loop through each item in your listbox collection , since it is comma delimited (each char) it should be easy enough to get substring that you want.

      1 Reply Last reply
      0
      • J jaakinye

        I have listbox with the follwing data from the base: rownumber,a1,a2,a3,a4,a5,a6 1 1,2,3,6,5,4 2 3,2,9,5,7,5 3 4,5,2,8,9,7 4 9,9,8,2,3,5 5 9,8,5,1,2,4 6 7,3,6,8,4,9 etc,etc,etc I have 2 textbox textbox1 = the 3rd data in 2nd row textbox2 = the 5th data in 4th row How do I get these by code? can someone help? Tahnks :laugh:

        jaakinye

        V Offline
        V Offline
        vaghelabhavesh
        wrote on last edited by
        #3

        If you know which item you want to get, then you can use ListBox.Items collection. You need to pass the index of the row you are intersted. After getting that value you can split the value using Split method and providing the separator, which will return the string array. Then you can grab the intended the value. :-)

        C#:
        textBox1.Text = listBox1.Items[1].ToString().Split(new char[] { ',' })[2];
        textBox2.Text = listBox1.Items[3].ToString().Split(new char[] { ',' })[4];

        VB:
        textBox1.Text = listBox1.Items(1).ToString().Split(New Char() {","c})(2)
        textBox2.Text = listBox1.Items(3).ToString().Split(New Char() {","c})(4)

        J 1 Reply Last reply
        0
        • V vaghelabhavesh

          If you know which item you want to get, then you can use ListBox.Items collection. You need to pass the index of the row you are intersted. After getting that value you can split the value using Split method and providing the separator, which will return the string array. Then you can grab the intended the value. :-)

          C#:
          textBox1.Text = listBox1.Items[1].ToString().Split(new char[] { ',' })[2];
          textBox2.Text = listBox1.Items[3].ToString().Split(new char[] { ',' })[4];

          VB:
          textBox1.Text = listBox1.Items(1).ToString().Split(New Char() {","c})(2)
          textBox2.Text = listBox1.Items(3).ToString().Split(New Char() {","c})(4)

          J Offline
          J Offline
          jaakinye
          wrote on last edited by
          #4

          Thanks so much Every thing is working well :laugh:

          jaakinye

          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