Code to Manipulate Lists

  1. Using the initialized ListManager object, oListManager, created in Code to Initialize the ListManager Object, create a new empty list named 'Users2'.

    Dim vListID2
    vListID2 = oListManager.CreateEmpty("Users2", "More users", 20, 0)
    
  2. Copy the list, 'Users1', created in Code to Create a List to the new list.

    oListManager.Copy "Users1", vListID2, False
    
  3. Delete three members from the 'Users2' list.

    oListManager.RemoveUserFromMailingList "Users2", _
     "barneyuser@fabrikam.com"
    
    oListManager.RemoveUserFromMailingList "Users2", _
     "jackuser@vigorairlines.com"
    
    oListManager.RemoveUserFromMailingList "Users2", _
     "jilluser@microsoft.com"
    
  4. Add two new users to the 'Users2' list.

    oListManager.AddUserToMailingList "Users2", _
     "janeuser@fabrikam.com", Newuser_F554
    
    oListManager.AddUserToMailingList "Users2", _
     "freduser@vigorairlines.com", Newuser_V919
    
  5. Perform a union and a subtraction on the 'Users1' and 'Users2' lists. The lists holding the results of the union and subtraction operations must exist prior to running the methods. The results are shown in the following table.

    oListManager.CreateEmpty "Union", "Unique users", 20, 0
    oListManager.CreateEmpty "Subtract", "Remaining users", 20, 0
    oListManager.Union "Users1", "Users2", "Union", 0, False
    oListManager.Subtract "Users1", "Users2", "Subtract", 0, False
    
    Users1 Users2 Union Substact
    joeuser@roguecellars.com joeuser@roguecellars.com joeuser@roguecellars.com barneyuser@fabrikam.com
    barneyuser@fabrikam.com bettyuser@arborshoes.com barneyuser@fabrikam.com jackuser@vigorairlines.com
    bettyuser@arborshoes.com janeuser@fabrikam.com bettyuser@arborshoes.com jilluser@microsoft.com
    jackuser@vigorairlines.com freduser@vigorairlines.com jackuser@vigorairlines.com    
    jilluser@microsoft.com     jilluser@arborshoes.com    
            janeuser@fabrikam.com    
            freduser@vigorairlines.com
  6. Export the Union list to a SQL Server database table named NewUsers, overwriting any previous data. Once the operation is complete, delete the list.

    sConnect = "Provider=sqloledb;Data Source=TequillaServer;" & _
     "Initial Catalog=Margaritas;User ID=userid;Password=******"
    
    oListManager.ExportToSQL "Union", sConnect, "NewUsers", True, 0, False
    
    oListManager.Delete "Union"
    


All rights reserved.