Login   /   Register

Dictionary of Employees

Rate this article
     2 votes, average: 4 out of 52 votes, average: 4 out of 52 votes, average: 4 out of 52 votes, average: 4 out of 52 votes, average: 4 out of 5
Loading ... Loading ...
April 1st, 2008 by daniva

Demonstration script that combines the usage of classes and dictionary object. Script must be run on the local computer.

Class Employee
    Private fname,lname,m_id,m_city,m_country
 
    Public Property Get FirstName()
        FirstName = fname
    End Property
    Public Property Let FirstName( value )
        fname = value
    End Property    
    Public Property Get LastName()
        LastName = lname
    End Property
    Public Property Let LastName( value )
        lname = value
    End Property
    Public Property Get Id()
        Id = m_id
    End Property
    Public Property Let Id( value )
        m_id = value
    End Property
     Public Property Get City()
        City = m_city
    End Property
    Public Property Let City( value )
        m_city = value
    End Property  
     Public Property Get Country()
        Country = m_country
    End Property
    Public Property Let Country( value )
        m_country = value
    End Property         
End Class
 
Set listEmployee = CreateObject( "Scripting.Dictionary" )
listEmployee.Add "1", New Employee
listEmployee( "1" ).Id = "3425789734"
listEmployee( "1" ).FirstName = "Dani"
listEmployee( "1" ).LastName = "Vainstein"
listEmployee( "1" ).City = "Petaj Tikva"
listEmployee( "1" ).Country = "Israel"
listEmployee.Add "2", New Employee
listEmployee( "2" ).Id = "456875677"
listEmployee( "2" ).FirstName = "Sara"
listEmployee( "2" ).LastName = "Vainstein"
listEmployee( "2" ).City = "BatYam"
listEmployee( "2" ).Country = "Israel"
' ** Printing
For nEmp = 1 To listEmployee.Count
    Print "Employee No: " & nEmp
    Print listEmployee( Cstr( nEmp ) ).FirstName
    Print listEmployee( Cstr( nEmp ) ).LastName
    Print listEmployee( Cstr( nEmp ) ).Country
Next

Posted in Dictionary Objects

3 Responses to “Dictionary of Employees”

  1. heqingbluesky Says:

    [+]

    I found this article is pretty useful for me to fully understand the concept of dictionary object and class. But I found a prob... ...

  2. daniva Says:

    [+]

    is hard to understand the term "your QTP" i debugged the script, and it works find. one issue might have a problem QTP yelds sy... ...

  3. guyofu Says:

    [-]

    cool stuff.really helpful

Leave a Reply

You must be logged in to post a comment.

This article was viewed 570 times