Removing an array item. How hard?
Hi all, working with a bunch of image control in an array. How would I go about removing one of the image control (array item) and replace it with the one next to it, and then reduce the array size to "array size - 1"?
In my case, user creates bunch of thumnails and later by right clicking on one of them, the thumbnail would automatically be deleted from the array and rest of the existing thumbnails on the right of it would be relocated to fill up the gap.
VB Code:
Option Explicit
Public thm As Integer
Private Sub Form_Load()
thm = thm + 1
End Sub
'To add each thumbnails (works fine)
Private Sub MakeThmnails_Click()
Static lCounter As Long
Load Image2(thm) ' Create new button.
Image2(thm).Top = 0
Image2(thm).Left = Image2(thm - 1).Left + 50 + Image2(thm - 1).Width
'Set new control to the right of previous
Image2(thm).Visible = True
Image2(thm).Stretch = True
Image2(thm).BorderStyle = 1
Image2(thm).ToolTipText = Combo1.Text
Picture1.Width = Picture1.Width + 1092
Image2(thm).Picture = LoadPicture(File2.Path & "\" & File2.List(lCounter))
thm = thm + 1
End Sub
With code below I can remove all the thumnails to the right of the one user right clicks on but that's about as far as I've succeeded.
Thanks in advance.
VB Code:
'Remove code (needs to be modified)
Private Sub Image2_MouseDown(Index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 2 Then
For thm = Index To thm - 1
Unload Image2(thm)
Next
thm = Index
End If
End Sub