[vb.net 2005] Split listbox into textbox?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DaWofl
    New Member
    • Sep 2007
    • 2

    [vb.net 2005] Split listbox into textbox?

    Iam reading text from a textfile iam splitting it by # at te end of the line so get al lines into my listbox like this

    Code:
            aryTextFile = LineOfText.Split("#")
            For i = 0 To UBound(aryTextFile)
                ListBox1.Items.Add(aryTextFile(i))
            Next i
    listbox shows "name,surname,p honenumer" rows.
    When i select one i want it to show in 3 textboxes, (txtname, txtsurname, txtnumber).

    i know i can use listbox.selecte ditem but then i get the entire row. Is it even possible to split it again from the listbox?
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Once you grab the SelectedIndex a SelectedObjectC ollection will be returned to you so that you can manipulate this data.

    See MSDN's article on ListBox.Selecte dObjectCollecti on Class for more information on how to manipulate this data.

    -Frinny

    Comment

    • DaWofl
      New Member
      • Sep 2007
      • 2

      #3
      Ok i dont know exactly know what u mean cause i never used that command before but iam looking into it :)

      *edit

      Ok u certainly pushed me into the right direction :) this is what i came up with

      Code:
       
              Dim strSelItems(ListBox1.SelectedItems.Count - 1) As String
              Dim splitten As String
              Dim gesplit() As String
      
              For intI As Integer = 0 To ListBox1.SelectedItems.Count - 1
                  strSelItems(intI) = ListBox1.SelectedItems.Item(intI).ToString
              Next
              For intI As Integer = 0 To strSelItems.Length - 1
                  MsgBox(strSelItems(intI))
                  txttesten.Text = strSelItems(intI)
                  splitten = strSelItems(intI)
                  gesplit = splitten.Split(",")
                  txttesten2.Text = gesplit(0)
              Next
      And its workgin now i can finaly finish this project :) (study)

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        Originally posted by DaWofl
        Ok i dont know exactly know what u mean cause i never used that command before but iam looking into it :)

        *edit

        Ok u certainly pushed me into the right direction :) this is what i came up with

        Code:
         
                Dim strSelItems(ListBox1.SelectedItems.Count - 1) As String
                Dim splitten As String
                Dim gesplit() As String
        
                For intI As Integer = 0 To ListBox1.SelectedItems.Count - 1
                    strSelItems(intI) = ListBox1.SelectedItems.Item(intI).ToString
                Next
                For intI As Integer = 0 To strSelItems.Length - 1
                    MsgBox(strSelItems(intI))
                    txttesten.Text = strSelItems(intI)
                    splitten = strSelItems(intI)
                    gesplit = splitten.Split(",")
                    txttesten2.Text = gesplit(0)
                Next
        And its workgin now i can finaly finish this project :) (study)
        That's Great :)

        Thanks for sharing the solution with us!

        -Frinny

        Comment

        Working...