Delete All Items from NewListBox

Post a reply

Smilies
:D :) :( :o :-? 8) :lol: :x :P :oops: :cry: :evil: :roll: :wink:

BBCode is ON
[img] is ON
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Delete All Items from NewListBox

Re: Delete All Items from NewListBox

by Thanasis » Mon Nov 28, 2011 9:19 am

Thank you brother Eyal.

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

Thanks again

Re: Delete All Items from NewListBox

by Eyal » Sun Nov 27, 2011 5:22 pm

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 :~)

Delete All Items from NewListBox

by Thanasis » Sun Nov 27, 2011 6:06 am

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.

Top