‘Calculate gross salary
Option explicit
Dim emp(100), noe, i, comm,
gsal
'Read No: of employees
noe=inputbox("Enter No:
of employees")
For i=0 to noe-1 step 1
emp(i)=inputbox("Enter employee basic salary")
Next
'Calculate gross salary
For i=0 to noe-1 step 1
If emp(i)>=30000 Then
comm=emp(i)*10/100
gsal=emp(i)+comm
emp(i)=gsal
elseif emp(i)<30000 and emp(i)>=15000 then
comm=emp(i)*5/100
gsal=emp(i)+comm
emp(i)=gsal
else
comm=200
gsal=emp(i)+comm
emp(i)=gsal
End If
Next
'Disply gross salary
For i=0 to noe-1 step 1
print emp(i)
Next
‘Note pad + Regular Expression
Option explicit
Dim fso, fo, x, r, ms, m
Set fso=
createobject("scripting.Filesystemobject")
Set fo=
fso.OpenTextFile("c:\testdata.txt",1,false)
Set r=new regexp
r.pattern="([a-z]+[0-9]+[a-z0-9]*)|([0-9]+[a-z]+[a-z0-9]*)"
r.global=True
While
fo.AtEndOfStream<> True
x=fo.ReadLine
Set ms=r.execute(x)
For each m in ms
msgbox m.value
Next
Wend
fo.Close
Set fo=nothing
Set fso=nothing
‘Copy notepad data into another notepad
Option explicit
Dim fso, fo1, fo2, x
Set
fso=createobject("scripting.Filesystemobject")
Set
fo1=fso.OpenTextFile("C:\testdata.txt",1,false)
Set
fo2=fso.OpenTextFile("C:\testresults.txt",2, true)
While
fo1.AtEndOfStream<>true
x=fo1.ReadLine
fo2.Writeline(x)
fo2.WriteBlankLines(3)
Wend
fo1.Close
fo2.Close
Set fo1=nothing
Set fo2=nothing
Set fso=nothing
‘Print all desktop sub folder names
Option explicit
Dim fso, foo, sfs, sf
Set
fso=createobject("scripting.Filesystemobject")
Set foo=fso.GetFolder("C:\WINDOWS")
set sfs=foo.SubFolders
For each sf in sfs
print sf.name
Next
Set sfs=nothing
Set foo=nothing
Set fso=nothing
‘Print all text files names
Option explicit
Dim fso, foo, fs, f, x, y
Set
fso=createobject("Scripting.Filesystemobject")
Set foo=fso.GetFolder("C:\WINDOWS")
Set fs=foo.Files
For each f in fs
x=f.name
y=split(x,".")
If y(1)="txt" Then
print x
End If
Next
Set fs=nothing
Set foo=nothing
Set fso=nothing
‘Used space in C drive
Option explicit
Dim fso, dro, x, y, z
Set fso=createobject("Scripting.Filesystemobject")
Set
dro=fso.GetDrive("C")
x=dro.TotalSize
x=x/(1024*1024*1024)
y=dro.FreeSpace
y=y/(1024*1024*1024)
z=x-y
msgbox("Used space in C
drive is "&z)
Set dro=nothing
Set fso=nothing
‘Design Excel sheet cells
Option explicit
Dim exo, wbo, wso, r, i, x,
y, z
Set
exo=createobject("Excel.Application")
exo.Visible=true
Set
wbo=exo.Workbooks.Open("C:\mindq.xls")
Set
wso=wbo.Worksheets("Sheet1")
r=wso.usedrange.rows.count
For i=2 to r step 1
x=wso.cells(i,1)
y=eval(x)
z=wso.cells(i,2)
If cint(y)=cint(z) Then
wso.cells(i,3)="Passed"
wso.cells(i,3).font.colorindex=4
wso.cells(i,3).interior.colorindex=1
wso.cells(i,3).font.bold=true
wso.cells(i,3).font.name="verdana"
wso.cells(i,3).font.size=15
else
wso.cells(i,3)="Failed"
wso.cells(i,3).font.colorindex=3
wso.cells(i,3).font.bold=true
wso.cells(i,3).font.name="verdana"
wso.cells(i,3).font.size=15
End If
Next
wbo.Save
exo.Quit
Set wso=nothing
Set wbo=nothing
Set exo=nothing
‘Verify the different login details in excel sheet
Option explicit
Dim bro, url, exo, wbo, wso,
rc, i, u, p, c, x, y
'Open excel
Set
exo=createobject("Excel.Application")
Set
wbo=exo.Workbooks.Open("C:\users.xls")
Set
wso=wbo.Worksheets("sheet1")
rc=wso.usedrange.rows.count
For i=2 to rc step 1
'Launch site
bro="c:\program files\internet
explorer\iexplore.exe"
url="http://127.0.0.1:1080/WebTours/"
invokeapplication bro&" "&url
'get data from excel sheet
u=wso.cells(i,1)
p=wso.cells(i,2)
c=wso.cells(i,3)
'login
With Browser("title:=Web
Tours").page("title:=Web Tours")
.webedit("name:=username").set u
.webedit("name:=password").set p
.image("name:=login").click
End With
'get content for
valid user
If c="valid" Then
With Browser("title:=Web Tours").page("title:=Web
Tours")
With
.frame("name:=info")
With
.webelement("html tag:=BLOCKQUOTE")
x=.getroproperty("innertext")
End With
End With
End With
'check the content for valid user
If
instr(x,"Welcome, jojo") Then
reporter.ReportEvent
micpass,"content test","correct msg"
else
reporter.ReportEvent
micfail,"content test","incorrect msg"
End If
'Logout for valid user
With Browser("title:=Web
Tours").page("title:=Web Tours")
With
.frame("name:=navbar")
.image("name:=Image","index:=3").click
End With
End With
End If
'get content for invalid user
If c="invalid" Then
With Browser("title:=Web
Tours").page("title:=Web Tours")
With
.frame("name:=info")
y=.webelement("html
tag:=B").getroproperty("innertext")
End With
End With
If instr(y,"Error") Then
reporter.ReportEvent
micpass,"content test","correct msg"
else
reporter.ReportEvent
micfail,"content test","incorrect msg"
End If
End If
'Close site
Browser("title:=Web Tours").Close
Next
exo.Quit
Set wso=nothing
Set wbo=nothing
No comments:
Post a Comment