I think this does what you want.------------------Code:Dim MyCollection As New Collection ' Create a collection to hold Images sorted by Top Dim intIndex As Integer Dim intIndex2 As Integer Dim bAdded As Boolean ' Examine all the controls on the form For intIndex = 0 To Me.Controls.Count - 1 If TypeOf Me.Controls(intIndex) Is Image Then ' It's an Image so add it to the collection If MyCollection.Count > 0 Then ' There are items in the collection, so compare their Top ' property to the Top property of the Image to be added For intIndex2 = 1 To MyCollection.Count bAdded = False If Me.Controls(intIndex).Top > MyCollection.Item(intIndex2).Top Then ' It's greater so add the new Image before the one in the ' collection we are comparing it to. The format of the Add statement ' is "CollectionName, IndexString, Before" MyCollection.Add Me.Controls(intIndex), Str(Me.Controls(intIndex).Top), intIndex2 bAdded = True Exit For End If Next intIndex2 If Not bAdded Then MyCollection.Add Me.Controls(intIndex), Str(Me.Controls(intIndex).Top) End If Else ' It's the first item in the collection, so just add it MyCollection.Add Me.Controls(intIndex), Str(Me.Controls(intIndex).Top) End If End If Next intIndex For intIndex = 1 To MyCollection.Count MyCollection.Item(intIndex).ZOrder Next
Marty




Reply With Quote