Вы находитесь на странице: 1из 3

Assignment-4

1. Write a program(WAP) to demonstrate to show the scope of Dim, Private and


Public variables?
Answer
Scope of Dim
Dim var1
Dim var2
Function abc()
Var1=10
Var2=20
Dim var3

var3 cannot be accessed outside the abc()

Var3= var1 + var2


Msgbox var3

Scope of Public
Dim var1
Dim var2
public var3 var3 can be accessed in all the actions
Function abc()
Var1=10
Var2=20
Var3= var1 + var2
Msgbox var3
Private and public specifiers cannot be declared within the procedure

2. WAP to get input number and convert it to number and use it to generate
random numbers?

Dim inputVariable
inputVariable = InputBox("Enter number")

Dim Value
Randomize
Value = Int((inputVariable * Rnd) + 1) ' Generate random value between 1 and
100.
MsgBox Value
3. WAP to reverse string without using strreverse method?

MyStr = inputbox("Enter the String:")


nCnt = Len(MyStr)
For i = 1 to nCnt
RevStr = Mid(MyStr,i,1)&RevStr
Next
Msgbox RevStr
4. WAP to get all characters from a string ?

strString = "test"
For i=1 To Len(strString)
WScript.Echo Mid(strString,i,1)
Next
5. WAP to find *.txt files in a folder, if it is older than 1 day, delete it?

Dim oFS,objfile,f
Set oFS = CreateObject("Scripting.FileSystemObject")
Set f = oFS.GetFolder("C:\Users\Administrator\Desktop\New folder\bunty")
For Each objfile in f.Files
if objfileDateCreated<(Now()-1) Then
objfile.Delete(True)
end if
Next
6. Generate the random number in given range 1 -100?


Dim Value
Randomize
Value = Int((inputVariable * Rnd) + 1) ' Generate random value between 1 and
100.
MsgBox Value
7. Store an array variable into dictionary and display its contents?

Set d = CreateObject("Scripting.Dictionary")
d.Add "Company", Array("microsoft", "apple")
WScript.Echo Join(d("Company"))
8. Create object of Win32 API and with it loop through all process names?

9. Name the Utilities available in qtp? And explain any five in detail.
10.Explain the working of the OR comparison tool?
11.Explain working of OR merge tool?
12.Explain usage of regular expression tool with example ?.

Вам также может понравиться