title: visual basic array sorting from list box
body: <p>Hello im having trouble with my code !
  we are asked to organize a list of names from a text.txt file the make them show up into a lits box (got that part down :) ) . then from the list box we are asked to create an array and sort that array (using our own sorting method) and organize the names using a button in assending order and another button organizing the array in decending order. the results from the orders names should appear in another list box .
  i have gotten only the last name in the list to show up in the second list box but my code has no errors it just wont order the names properly! Help!!!!!</p>
  
  <p>here is my code :)</p>
  
  <pre><code>Public Class FileSort
  Dim sr As IO.StreamReader = IO.File.OpenText("C:\Users\Inspiron 15\documents\visual studio 2010\Projects\assigment4 EL\assigment4 EL\names.txt")
  
  Structure names
  Dim c As Integer
  Dim fullname As String
  End Structure
  
  Dim allNames(99) As names
  
  Private Sub btnName_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnName.Click
  
   Do While sr.Peek &lt;&gt; -1
      Name = sr.ReadLine
      LstNames.Items.Add(Name &amp; " ")
  Loop
  sr.Close()
  
  End Sub
  Private Sub bubbelsort(ByRef names() As System.String, ByVal c As Integer)
  c = 0
  names(c) = sr.ReadLine()
  c = c * 1
  For c = 1 To 99 Step +1 '~~~ Addding (Z to A) to the the Listbox
      lstOrderedNames.Items.Add(Name &amp; "")'
  Next
  
  End Sub
  Private Sub BtnAssend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnAssend.Click
  
  Dim names(99) As String
  Dim c As Integer
  c = 0
  Dim A As Integer
  A = 99
  names(c) = sr.ToString
  c = c + 1
  For c = 1 To 99 Step +1 '~~~ Addding (Z to A) to the the Listbox
      lstOrderedNames.Items.Add(Name &amp; "")
  Next
  End Sub
  
  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnDessend.Click
  Dim names(99) As String
  Dim c As Integer
  c = 0
  Dim A As Integer
  A = 99
  names(c) = sr.ToString
  names(A) = sr.ToString
  A = A - 1
  For A = 99 To 0 Step -1 '~~~ Addding (Z to A) to the the Listbox
      lstOrderedNames.Items.Add(Name &amp; "")
  Next
  End Sub
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/mR3Xu.png" rel="nofollow noreferrer">enter image description here</a></p>