Right Click Disabled

Sunday, February 26, 2012

VBScript code in QTP to create a dictionary object to access a dictionary, to store five pairs of data into that dictionary and then to find total marks stored in that dictionary.

Option explicit
Dim dico, i, sn, m, lm, tot
'Here     i       for loop
'            sn     for subject name
'            m     for marks
'            lm    for list of marks
'            tot   for total
'Create dictionary object and add pairs of data
Set dico=CreateObject("Scripting.Dictionary")
For i=1 to 5 step 1
      sn=inputbox("Enter Subject Name : ")
      m=inputbox("Enter Marks : ")
      dico.Add sn,m
Next
'Find total marks in that dictionary
tot=0
lm=dico.Items
For each m in lm
      tot=tot+m
Next
Print("Total Marks is :"&tot)
Set dico=nothing

No comments:

Post a Comment

Twitter Bird Gadget