Monday, 28 March 2011

QTP @ Dictionary Object >> KeyExists

Leave a Comment

QTP @ Dictionary Object >> KeyExists

0        '##############################################
0        ' Dictionary Object >> KeyExistsDemo
0        '##############################################
0        Print "##############################################"
0        Print " Dictionary Object >> KeyExistsDemo"
0        Print "##############################################"
0        Function KeyExistsDemo()
0        '   Dim oDict, msg   ' Create some variables.
0           Set oDict = CreateObject("Scripting.Dictionary")
0                        oDict.Add "Subject", "QuickTestQTP"   ' Add some keys and items.
0                        oDict.Add "Teacher", "GAReddy"
0                        oDict.Add "Learner1", "SomeBody"
0                        oDict.Add "Learner2", "SomeBodyElse"
0           If oDict.Exists(" Learner2 ") Then
0              msg = "Specified key exists."
0           Else
0              msg = "Specified key doesn't exist."
0           End If
0           KeyExistsDemo = msg
0        End Function

Read More...

QTP @ Dictionary Object >> RemoveAll Method

Leave a Comment

QTP @ Dictionary Object >> RemoveAll

0        '##############################################
0        ' Dictionary Object >> RemoveAll
0        '##############################################
0        Print "##############################################"
0        Print " Dictionary Object >> RemoveAll"
0        Print "##############################################"
0        'RemoveAll
0        'Dim a, d, i   ' Create some variables.
0        Set oDict = CreateObject("Scripting.Dictionary")
0        oDict.Add "Subject", "QuickTestQTP"   ' Add some keys and items.
0        oDict.Add "Teacher", "GAReddy"
0        oDict.Add "Learner1", "SomeBody"
0        oDict.Add "Learner2", "SomeBodyElse"
0        a = oDict.RemoveAll   ' Clear the dictionary.
0         
0        For each ditem in oDict
0                        Print oDict.Item(ditem)
0         Next
Read More...

QTP @ Dictionary Object >> Remove Method

Leave a Comment

QTP @ Dictionary Object >> Remove

0        '##############################################
0        ' Dictionary Object >> Remove
0        '##############################################
0        Print "##############################################"
0        Print " Dictionary Object >> Remove"
0        Print "##############################################"
0        'Remove
0        'Dim a, d   ' Create some variables.
0        Set oDict = CreateObject("Scripting.Dictionary")
0        oDict.Add "Subject", "QuickTestQTP"   ' Add some keys and items.
0        oDict.Add "Teacher", "GAReddy"
0        oDict.Add "Learner1", "SomeBody"
0        oDict.Add "Learner2", "SomeBodyElse"
0        oDict.Remove("Learner2")   ' Remove Learner2 pair.
0         
0        For each ditem in oDict
0                        Print oDict.Item(ditem)
0         Next
Read More...

QTP @ Dictionary Object >> Add Method

Leave a Comment

QTP @ Dictionary Object >> Add

0        '##############################################
0        ' Dictionary Object >> Add
0        '##############################################
0        Print "##############################################"
0        Print " Dictionary Object >> Add"
0        Print "##############################################"
0        'Add
0        Dim oDict   ' Create a variable.
0        Set d = CreateObject("Scripting.Dictionary")
0        oDict.Add "Subject", "QuickTestQTP"   ' Add some keys and items.
0        oDict.Add "Teacher", "GAReddy"
0        oDict.Add "Learner", "SomeBody"
0        '####################################

Read More...

QTP @ Dictionary Object > Creating a Dictionary Object

Leave a Comment

QTP @ Creating a Dictionary Object

0        '--- Creating a dictionary object
0        Set oDict = CreateObject("Scripting.Dictionary")
0        '--- Adding items to dictionary
0        oDict.Add "Name", "GAReddy"
0        oDict.Add "Address", "Hyderabad"
0        oDict.Add "Phone", "0123456789"
0        oDict.Add "Demo", "QTP"
0        oDict.Add "Blog", "QuickTestQTP"
0        oDict.Add "BlogURL", "Http://QuickTestQTP.BlogSpot.com/"
0        '--- Looping the Collection
0        For Each vKey In oDict
0        sItem = oDict.Item(vKey)
0        sMsg = sMsg & sItem & vbCrLf
0        Next
0        MsgBox sMsg

Read More...

Monday, 28 March 2011

QTP @ Dictionary Object >> KeyExists


QTP @ Dictionary Object >> KeyExists

0        '##############################################
0        ' Dictionary Object >> KeyExistsDemo
0        '##############################################
0        Print "##############################################"
0        Print " Dictionary Object >> KeyExistsDemo"
0        Print "##############################################"
0        Function KeyExistsDemo()
0        '   Dim oDict, msg   ' Create some variables.
0           Set oDict = CreateObject("Scripting.Dictionary")
0                        oDict.Add "Subject", "QuickTestQTP"   ' Add some keys and items.
0                        oDict.Add "Teacher", "GAReddy"
0                        oDict.Add "Learner1", "SomeBody"
0                        oDict.Add "Learner2", "SomeBodyElse"
0           If oDict.Exists(" Learner2 ") Then
0              msg = "Specified key exists."
0           Else
0              msg = "Specified key doesn't exist."
0           End If
0           KeyExistsDemo = msg
0        End Function

QTP @ Dictionary Object >> RemoveAll Method


QTP @ Dictionary Object >> RemoveAll

0        '##############################################
0        ' Dictionary Object >> RemoveAll
0        '##############################################
0        Print "##############################################"
0        Print " Dictionary Object >> RemoveAll"
0        Print "##############################################"
0        'RemoveAll
0        'Dim a, d, i   ' Create some variables.
0        Set oDict = CreateObject("Scripting.Dictionary")
0        oDict.Add "Subject", "QuickTestQTP"   ' Add some keys and items.
0        oDict.Add "Teacher", "GAReddy"
0        oDict.Add "Learner1", "SomeBody"
0        oDict.Add "Learner2", "SomeBodyElse"
0        a = oDict.RemoveAll   ' Clear the dictionary.
0         
0        For each ditem in oDict
0                        Print oDict.Item(ditem)
0         Next

QTP @ Dictionary Object >> Remove Method


QTP @ Dictionary Object >> Remove

0        '##############################################
0        ' Dictionary Object >> Remove
0        '##############################################
0        Print "##############################################"
0        Print " Dictionary Object >> Remove"
0        Print "##############################################"
0        'Remove
0        'Dim a, d   ' Create some variables.
0        Set oDict = CreateObject("Scripting.Dictionary")
0        oDict.Add "Subject", "QuickTestQTP"   ' Add some keys and items.
0        oDict.Add "Teacher", "GAReddy"
0        oDict.Add "Learner1", "SomeBody"
0        oDict.Add "Learner2", "SomeBodyElse"
0        oDict.Remove("Learner2")   ' Remove Learner2 pair.
0         
0        For each ditem in oDict
0                        Print oDict.Item(ditem)
0         Next

QTP @ Dictionary Object >> Add Method


QTP @ Dictionary Object >> Add

0        '##############################################
0        ' Dictionary Object >> Add
0        '##############################################
0        Print "##############################################"
0        Print " Dictionary Object >> Add"
0        Print "##############################################"
0        'Add
0        Dim oDict   ' Create a variable.
0        Set d = CreateObject("Scripting.Dictionary")
0        oDict.Add "Subject", "QuickTestQTP"   ' Add some keys and items.
0        oDict.Add "Teacher", "GAReddy"
0        oDict.Add "Learner", "SomeBody"
0        '####################################

QTP @ Dictionary Object > Creating a Dictionary Object


QTP @ Creating a Dictionary Object

0        '--- Creating a dictionary object
0        Set oDict = CreateObject("Scripting.Dictionary")
0        '--- Adding items to dictionary
0        oDict.Add "Name", "GAReddy"
0        oDict.Add "Address", "Hyderabad"
0        oDict.Add "Phone", "0123456789"
0        oDict.Add "Demo", "QTP"
0        oDict.Add "Blog", "QuickTestQTP"
0        oDict.Add "BlogURL", "Http://QuickTestQTP.BlogSpot.com/"
0        '--- Looping the Collection
0        For Each vKey In oDict
0        sItem = oDict.Item(vKey)
0        sMsg = sMsg & sItem & vbCrLf
0        Next
0        MsgBox sMsg