Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2014
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.98 KB | None | 0 0
  1. Public Class Form1
  2.  
  3. Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
  4. Dim DescendingButton As New Button
  5. DescendingButton.Location = New System.Drawing.Point(196, 70)
  6. DescendingButton.Name = "DescendingButton"
  7. DescendingButton.Size = New System.Drawing.Size(75, 23)
  8. DescendingButton.TabIndex = 2
  9. DescendingButton.Text = "Descending"
  10. DescendingButton.UseVisualStyleBackColor = True
  11. AddHandler DescendingButton.Click, AddressOf DescendingButtonClicked
  12. Controls.Add(DescendingButton)
  13.  
  14. End Sub
  15. Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
  16.  
  17. End Sub
  18. Private Sub DescendingButtonClicked(ByVal sender As System.Object, ByVal e As System.EventArgs)
  19. TextBox1.Text.Split(",").Count()
  20. Dim temp As Integer
  21. Dim array(50) As Integer
  22. Dim count As Integer
  23. Dim numbers() As String
  24. Dim result As String
  25.  
  26. numbers = TextBox1.Text.Split(",")
  27. count = numbers.Count
  28.  
  29.  
  30. For index As Integer = 0 To count - 1
  31. array(index) = Convert.ToInt32(numbers(index))
  32. Next
  33.  
  34. For index As Integer = 0 To count - 1
  35. For index2 As Integer = 0 To count - 2 - index
  36. If array(index2) > array(index2 + 1) Then
  37. temp = array(index2)
  38. array(index2) = array(index2 + 1)
  39. array(index2 + 1) = temp
  40. End If
  41. Next
  42. Next
  43.  
  44. For index As Integer = 0 To count - 1
  45. If index = count - 1 Then
  46. result += array(index).ToString()
  47. Else
  48. result += array(index).ToString() + ","
  49. End If
  50. Next
  51. Label1.Text = result
  52.  
  53. End Sub
  54.  
  55.  
  56. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  57.  
  58. TextBox1.Text.Split(",").Count()
  59. Dim temp As Integer
  60. Dim array(50) As Integer
  61. Dim count As Integer
  62. Dim numbers() As String
  63. Dim result As String
  64.  
  65. numbers = TextBox1.Text.Split(",")
  66. count = numbers.Count
  67.  
  68.  
  69. For index As Integer = 0 To count - 1
  70. array(index) = Convert.ToInt32(numbers(index))
  71. Next
  72.  
  73. For index As Integer = 0 To count - 1
  74. For index2 As Integer = 0 To count - 2 - index
  75. If array(index2) > array(index2 + 1) Then
  76. temp = array(index2)
  77. array(index2) = array(index2 + 1)
  78. array(index2 + 1) = temp
  79. End If
  80. Next
  81. Next
  82.  
  83. For index As Integer = 0 To count - 1
  84. If index = count - 1 Then
  85. result += array(index).ToString()
  86. Else
  87. result += array(index).ToString() + ","
  88. End If
  89. Next
  90. Label1.Text = result
  91.  
  92. End Sub
  93. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement