Dim NumArray(7) As Integer Dim Tempor1, Tempor2, Tempor3 As Integer Dim promt As String = "Please enter an integer:" Dim i As Integer Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ' This for next controls the entered numbers and asigns them to the array. For i = LBound(NumArray) To UBound(NumArray) NumArray(i) = InputBox(promt, , "Input Integers") Next i 'Llamar funciones de sorting. Call BubbleSortNumbers(Tempor1) TextBox1.Text = Tempor1 Call SelectionSortNumbers(Tempor2) TextBox2.Text = Tempor2 Call ShellSortNumbers(Tempor3) TextBox3.Text = Tempor3 End Sub 'Bubble sort Sub BubbleSortNumbers(ByVal iArray As Integer) Dim index1 As Long Dim index2 As Long Dim tempor As Long For index1 = UBound(iArray) To LBound(iArray) Step -1 For index2 = LBound(iArray) + 1 To index1 If iArray(index2 - 1) = iArray(index2) Then iArray(index2) = tempor End If Next index2 Next index1 End Sub 'Selection sort Sub SelectionSortNumbers(ByVal vArray) Dim index1 As Long Dim index2 As Long Dim min As Long Dim tempor As Long For index1 = LBound(vArray) To UBound(vArray) - 1 min = index1 For index2 = index1 + 1 To UBound(vArray) If vArray(index2) < vArray(min) Then min = index2 Next index2 tempor = vArray(min) vArray(min) = vArray(index1) vArray(index1) = tempor Next index1 End Sub 'Shell Sort Sub ShellSortNumbers(ByVal vArray) Dim index1 As Long Dim hold As Long Dim value As Long Dim tempor As Long value = LBound(vArray) Do value = 3 * value + 1 Loop Until value > UBound(vArray) Do value = value / 3 For index1 = value + LBound(vArray) To UBound(vArray) tempor = vArray(index1) hold = index1 Do While vArray(hold - value) > tempor vArray(hold) = vArray(hold - value) hold = hold - value If hold < value Then Exit Do Loop vArray(hold) = tempor Next index1 Loop Until value = LBound(vArray) End Sub End Class
And heres how the program should look like:

do you think that its better for me to change the textbox that hold the results for another tool?

New Topic/Question
Reply




MultiQuote




|