Question

Locked

Vb 2005 - arrays

By hiwalker62 ·
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 conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

You don't have option explicit on do you ?

by Tony Hopkinson In reply to Vb 2005 - arrays

temp1 ???

x an y arrays with dimensions of 4 indexed in a loop from 1 to 10


array of 10 items is a local variable in one method, and you want to sort it in another without passing it or making it a form property they can both refernce.

You need to take a couple of steps back mate, and ffs make sure option explicit is on.

Back to Software Forum
2 total posts (Page 1 of 1)  

Related Discussions

Related Forums