Delete All Items from NewListBox

This forum is for questions / discussions regarding development of addons / tweaks for MediaMonkey for Windows 4.

Moderators: Gurus, Addon Administrators

Thanasis
Posts: 84
Joined: Sun Aug 28, 2011 2:53 am

Delete All Items from NewListBox

Post by Thanasis »

Below, there is a stand alone (.vbs) fully working form with a fully loaded SDB.UI.NewListBox (Form)
Just run externally from your .vbs editor (or NotePad saved as .vbs ) .....

Is it any easy trick (with a single command if possible) that deletes all the content (all items) loaded in the form?

In other words, I am looking to reset the form so I load new (lb1.Items.Add) staff.....

Code: Select all

Dim SDB : Set SDB = CreateObject("SongsDB.SDBApplication")
SDB.ShutdownAfterDisconnect = False 
 
 
Set Form = SDB.UI.NewForm
Form.Common.SetRect 100, 100, 400, 400
Form.Caption = "Delete All"

 Set lb1 = SDB.UI.NewListBox(Form)
 
  lb1.Common.Left = 10
  lb1.Common.Top = 10
  lb1.Common.Height = 300
  lb1.Common.Width = 300
  
 For i = 0 To 10
 	lb1.Items.Add "Delete All " & i
 Next
 
 Form.ShowModal


'  ?  Command to Delete All items from lb1.Items.Delete  ?

Take care
Thanks in advance.
Eyal
Posts: 3116
Joined: Sun Jun 26, 2005 9:27 am
Location: Québec

Re: Delete All Items from NewListBox

Post by Eyal »

Hi Thanasis,

I don't think there's a method to delete all items at once,
but you can write a function to delete them, ex.:

Code: Select all

Sub Testscript
    Dim SDB : Set SDB = CreateObject("SongsDB.SDBApplication")
    SDB.ShutdownAfterDisconnect = False 
    
    Set Form = SDB.UI.NewForm
    Form.Common.SetRect 100, 100, 400, 400
    Form.Caption = "Delete All"
    
    Set lb1 = SDB.UI.NewListBox(Form)
    
      lb1.Common.Left = 10
      lb1.Common.Top = 10
      lb1.Common.Height = 300
      lb1.Common.Width = 300
      
    For i = 0 To 10
       lb1.Items.Add "Delete All " & i
    Next
    
    Form.ShowModal

    EmptyListBox(lb1)       'Delete all items from lb1

    Form.ShowModal
End Sub

' --------------------------------------------
' Function to to delete all items in a ListBox
Sub EmptyListBox(LB)
    Do While LB.Items.Count > 0
        LB.Items.Delete(0)
    Loop
End Sub
Eyal :~)
Skins for MediaMonkey: Cafe, Carbon, Helium, Spotify, Zekton. [ Wiki Zone ].
Thanasis
Posts: 84
Joined: Sun Aug 28, 2011 2:53 am

Re: Delete All Items from NewListBox

Post by Thanasis »

Thank you brother Eyal.

Not the most efficient way, but the only way :D

Thanks again
Post Reply