Question
February 5, 2008 at 05:49 AM
hiwalker62

Vb 2005 – arrays

by hiwalker62 . Updated 18 years, 9 months ago

Below is a task i have been set to build. I have to build an array of 10 inputs, when you click sort – it sorts the array 1, 3, 7, 12 etc…

Please help

Private Sub btnSort_Click(Index As Integer)
Dim count1 As Integer
Dim count2 As Integer
Dim temp As Integer
Dim xArray(4)
Dim yArray(4)

For count1 = 10 To 1 Step -1
For count2 = 1 To count1
num1 = xArray(count2 – 1)
num2 = yArray(count2)
If num1 < num2 Then temp = xArray(count2 - 1) temp1 = xArray(count2 - 1) = xArray(count2) xArray(count2) = temp End If Next count2 Next count1 End Sub Private Sub Command1_Click(Index As Integer) Dim myArray(10) As Integer Dim myCount As Integer 'Dim marked(51) As Integer If Me.text2 = "" Then Exit Sub End If Me.text2.SetFocus myArray(myCount) = Me.text2 If Me.Text3 = 4 Then Exit Sub Else Me.Text1 = Me.Text1 & myArray(myCount) & vbCrLf Me.Text3 = Me.Text3 + 1 Me.text2 = " " Exit Sub ' End If End Sub Private Sub Form_Activate() Me.text2.SetFocus Me.Text3 = 0 End Sub

This discussion is locked

All Comments