VBScript General Examples
VBScript General Examples
www.gcreddy.com
www.gcreddy.com
1) Write a program for finding out
1) Write a program for finding out whether the given year is a leap whether the given year is a leap year oryear or
not
not
Dim xyear Dim xyear
xyear=inputbox ("Enter Year") xyear=inputbox ("Enter Year")
If xyear mod 4=0 Then If xyear mod 4=0 Then
msgbox "This is a Leap year" msgbox "This is a Leap year" Ese Ese msgbox "This is !T" msgbox "This is !T" End If End If
!) Write a program for finding out
!) Write a program for finding out whether the given num"er is# Evenwhether the given num"er is# Even
num"er or $dd num"er
num"er or $dd num"er
Dim num Dim num
num=inputbox ("Enter a number") num=inputbox ("Enter a number")
If num mod #=0 Then If num mod #=0 Then
msgbox "This is a E$en !umber" msgbox "This is a E$en !umber" Ese
Ese
msgbox "This is a dd !umber" msgbox "This is a dd !umber" End If
End If
%) &ead two num"ers and display the sum
%) &ead two num"ers and display the sum
Dim num%&num#& sum Dim num%&num#& sum
num%=inputbox ("Enter num%") num%=inputbox ("Enter num%") num#=inputbox ("Enter num#") num#=inputbox ("Enter num#")
sum= 'db (num%) 'db (num#) if *e *ant add
sum= 'db (num%) 'db (num#) if *e *ant add t*o strings +on$ersiont*o strings +on$ersion re,uire
re,uire
msgbox ("-um is " .sum) msgbox ("-um is " .sum)
') &ead (##&
') &ead (##& values and *values and *alculate the alculate the Simple +nterestSimple +nterest
Dim p&t& r& si Dim p&t& r& si
p=inputbox ("Enter /rin+ipe") p=inputbox ("Enter /rin+ipe") t=inputbox ("Enter Time") t=inputbox ("Enter Time")
r=inputbox ("Enter ate of Interest") r=inputbox ("Enter ate of Interest")
si= (p1t1r)2%00 p= prin+ipe amount& t=time in years& r= rate of interest si= (p1t1r)2%00 p= prin+ipe amount& t=time in years& r= rate of interest
msgbox ("-impe Interest is " .si) msgbox ("-impe Interest is " .si)
,) &ead -our digit num"
,) &ead -our digit num"er# calculate disper# calculate display lay the sum of the num"er orthe sum of the num"er or
display Error message if the num"er is
display Error message if the num"er is not a four digit num"ernot a four digit num"er
Dim num& sum Dim num& sum
num=inputbox ("Enter a 3our digit
num=inputbox ("Enter a 3our digit number")number") If
If Len(num) Len(num) = = 4 Th4 Thenen sum=0
sum=0
sum=sumn
sum=sumnum mod um mod %0%0
num=num2%0 num=num2%0
num= eft (num& ) num= eft (num& )
1) Write a program for finding out
1) Write a program for finding out whether the given year is a leap whether the given year is a leap year oryear or
not
not
Dim xyear Dim xyear
xyear=inputbox ("Enter Year") xyear=inputbox ("Enter Year")
If xyear mod 4=0 Then If xyear mod 4=0 Then
msgbox "This is a Leap year" msgbox "This is a Leap year" Ese Ese msgbox "This is !T" msgbox "This is !T" End If End If
!) Write a program for finding out
!) Write a program for finding out whether the given num"er is# Evenwhether the given num"er is# Even
num"er or $dd num"er
num"er or $dd num"er
Dim num Dim num
num=inputbox ("Enter a number") num=inputbox ("Enter a number")
If num mod #=0 Then If num mod #=0 Then
msgbox "This is a E$en !umber" msgbox "This is a E$en !umber" Ese
Ese
msgbox "This is a dd !umber" msgbox "This is a dd !umber" End If
End If
%) &ead two num"ers and display the sum
%) &ead two num"ers and display the sum
Dim num%&num#& sum Dim num%&num#& sum
num%=inputbox ("Enter num%") num%=inputbox ("Enter num%") num#=inputbox ("Enter num#") num#=inputbox ("Enter num#")
sum= 'db (num%) 'db (num#) if *e *ant add
sum= 'db (num%) 'db (num#) if *e *ant add t*o strings +on$ersiont*o strings +on$ersion re,uire
re,uire
msgbox ("-um is " .sum) msgbox ("-um is " .sum)
') &ead (##&
') &ead (##& values and *values and *alculate the alculate the Simple +nterestSimple +nterest
Dim p&t& r& si Dim p&t& r& si
p=inputbox ("Enter /rin+ipe") p=inputbox ("Enter /rin+ipe") t=inputbox ("Enter Time") t=inputbox ("Enter Time")
r=inputbox ("Enter ate of Interest") r=inputbox ("Enter ate of Interest")
si= (p1t1r)2%00 p= prin+ipe amount& t=time in years& r= rate of interest si= (p1t1r)2%00 p= prin+ipe amount& t=time in years& r= rate of interest
msgbox ("-impe Interest is " .si) msgbox ("-impe Interest is " .si)
,) &ead -our digit num"
,) &ead -our digit num"er# calculate disper# calculate display lay the sum of the num"er orthe sum of the num"er or
display Error message if the num"er is
display Error message if the num"er is not a four digit num"ernot a four digit num"er
Dim num& sum Dim num& sum
num=inputbox ("Enter a 3our digit
num=inputbox ("Enter a 3our digit number")number") If
If Len(num) Len(num) = = 4 Th4 Thenen sum=0
sum=0
sum=sumn
sum=sumnum mod um mod %0%0
num=num2%0 num=num2%0
num= eft (num& ) num= eft (num& )
sum=sumn
sum=sumnum um mod mod %0%0
num=num2%0 num=num2%0
num= eft (num& #) num= eft (num& #) sum=sumn
sum=sumnum um mod mod %0%0
num=num2%0 num=num2%0
num= eft (num& %) num= eft (num& %) sum=sumnu
sum=sumnum m mod mod %0%0 msgbox ("-um is " .sum) msgbox ("-um is " .sum) ese
ese
msgbox "!umber& you entered is not a
msgbox "!umber& you entered is not a 4 digit number"4 digit number" End If
End If
/) &ead any -our0digit num"er and display the num"er in
/) &ead any -our0digit num"er and display the num"er in reverse orderreverse order
Dim num&re$ Dim num&re$
num= inputbox("Enter a number") num= inputbox("Enter a number") If en(num)=4 Then
If en(num)=4 Then
re$=re$1%0 num mod %0 re$=re$1%0 num mod %0 num=num2%0
num=num2%0 num= eft(num&) num= eft(num&)
re$=re$1%0 num mod %0 re$=re$1%0 num mod %0 num=num2%0
num=num2%0 num= eft(num&#) num= eft(num&#)
re$=re$1%0 num mod %0 re$=re$1%0 num mod %0 num=num2%0
num=num2%0 num= eft(num&%) num= eft(num&%)
re$=re$1%0 num mod %0 re$=re$1%0 num mod %0
msgbox "e$erse rder of the number is ".re$ msgbox "e$erse rder of the number is ".re$ Ese
Ese
msgbox "!umber& you entered is not a 4
msgbox "!umber& you entered is not a 4 digit number"digit number" End If
End If
) &ead ' su"2ects mar3s4 calculate the otal mar3s and grade
) &ead ' su"2ects mar3s4 calculate the otal mar3s and grade
(a) If a$erage mar5s 6reater than or e,ua to 78& grade
(a) If a$erage mar5s 6reater than or e,ua to 78& grade is Distin+tionis Distin+tion b) If a$erage mar5s 6reater than or e,ua to 90
b) If a$erage mar5s 6reater than or e,ua to 90 and ess than 78 & then and ess than 78 & then grade isgrade is 3irst
3irst
+) If a$erage mar5s 6reater than or e,ua to 80
+) If a$erage mar5s 6reater than or e,ua to 80 and ess than 90 & then and ess than 90 & then grade isgrade is -e+ond
-e+ond
d) If a$erage mar5s 6reater than or e,ua to 40
d) If a$erage mar5s 6reater than or e,ua to 40 and ess than 80 & then and ess than 80 & then grade isgrade is Third
Third
e) :inimum mar5s 8 for any sub;e+t& other*ise no grade fai) e) :inimum mar5s 8 for any sub;e+t& other*ise no grade fai)
Dim e&m&p&+& tot Dim e&m&p&+& tot
e=inputbox ("Enter engish :ar5s") e=inputbox ("Enter engish :ar5s") m=inputbox ("Enter maths :ar5s") m=inputbox ("Enter maths :ar5s") p=inputbox ("Enter physi+s :ar5s") p=inputbox ("Enter physi+s :ar5s") +=inputbox ("Enter +hemistry :ar5s") +=inputbox ("Enter +hemistry :ar5s")
tot= +db(e) +db(m) +db(p) +db(+) tot= +db(e) +db(m) +db(p) +db(+) msgbox tot
msgbox tot
If +db(e) <=8 and +db(m) <=8 and +db(p) <=8 and +db(+) <=8 and tot If +db(e) <=8 and +db(m) <=8 and +db(p) <=8 and +db(+) <=8 and tot <=00 Then
<=00 Then
msgbox "6rade is Distin+tion" msgbox "6rade is Distin+tion"
ese If
ese If +db(e) <=8 an+db(e) <=8 and +db(m) <=8 and +db(m) <=8 and +db(p) <=8 and +d +db(p) <=8 and +db(+) <=8 and totdb(+) <=8 and tot <=#40 and tot00 Then
<=#40 and tot00 Then msgbox "6rade is 3irst" msgbox "6rade is 3irst"
ese If +db(e) <=8 and +db(m) <=8 and +db(p) <=8 and +db(+) <=8 and ese If +db(e) <=8 and +db(m) <=8 and +db(p) <=8 and +db(+) <=8 and tottot <=#00 and tot#40 Then
<=#00 and tot#40 Then
msgbox "6rade is -e+ond" msgbox "6rade is -e+ond"
ese If +db(e) <=8 and +db(m) <=8 and +db(p) <=8 and +db(+) <=8 and ese If +db(e) <=8 and +db(m) <=8 and +db(p) <=8 and +db(+) <=8 and tottot <=%90 and tot#00 Then
<=%90 and tot#00 Then
msgbox "6rade is Third" msgbox "6rade is Third" ese
ese
msgbox "!o 6rade& 3ai" msgbox "!o 6rade& 3ai"
End If End If End If End If End If End If End If End If 5) 6isplay $dd num"ers up to n 5) 6isplay $dd num"ers up to n Dim num&n Dim num&n
n=Inputbox ("Enter a >aue") n=Inputbox ("Enter a >aue") 3or num= % to n step #
3or num= % to n step # msgbox num
msgbox num !ext
!ext
7) 6isplay Even num"ers up to n
7) 6isplay Even num"ers up to n
Dim num&n Dim num&n
n=Inputbox ("Enter a >aue") n=Inputbox ("Enter a >aue") 3or num= # to n step #
3or num= # to n step # msgbox num
msgbox num !ext
!ext
18) display natural num"ers up to n and write in
18) display natural num"ers up to n and write in a text filea text file
Dim num& n& fso& myfie Dim num& n& fso& myfie n= inputbox ("Enter any
n= inputbox ("Enter any >aue")>aue") num=%
num=%
3or num= % to n step % 3or num= % to n step % -et fso=
-et fso= +reateob;e+t ("s+ripting?fiesystemob;e+t+reateob;e+t ("s+ripting?fiesystemob;e+t")") set myfie=fso?opentextfie ("E@Ag+r?txt"& B& true) set myfie=fso?opentextfie ("E@Ag+r?txt"& B& true) myfie?*riteine num
myfie?*riteine num myfie?+ose
!ext
11) 6isplay 9atural num"ers in reverse order up to n
Dim num&n
n=Inputbox ("Enter a >aue") 3or num=n to % step C%
msgbox num !ext
1!) 6isplay 9atural num"ers sum up to n :;sing -or...9ext <oop)
Dim num& n& sum
n= inputbox ("Enter a >aue") sum=0
3or num= % to n step % sum= sumnum !ext
msgbox sum
1%) 6isplay 9atural num"ers sum up to n :using While...Wend <oop)
Dim num& n& sum
n= inputbox ("Enter a >aue") hie num =+db (n)
sum= sumnum num=num% end
msgbox sum
1') 6isplay 9atural num"ers sum up to n :;sing 6o...;ntil...<oop)
Dim num& n& sum
n= inputbox ("Enter a >aue") sum=0
num=% Do
sum= sumnum num=num%
Loop nti num =+db (n%) msgbox sum
1,) Write a -unction for 9atural 9um"ers sum up to n
3un+tion !!um'ou (n) Dim num& sum
sum=0
3or num= % to n step % sum= sumnum !ext
msgbox sum End 3un+tion
1/) Verify weather the entered 18 digit value is a numeric value or not
Dim a&x&y&F&num
num=Inputbox ("Enter a /hone !umber")
d%= eft (num&%) d%0=ight (num&%)
d#=mid (num& #& en (%)) d=mid (num& & en (%)) d4=mid (num& 4& en (%)) d8=mid (num& 8& en (%)) d9=mid (num& 9& en (%)) d7=mid (num& 7& en (%)) dB=mid (num& B& en (%)) dG=mid (num& G& en (%))
If isnumeri+ (d%) = "True" and isnumeri+ (d#) = "True" and isnumeri+ (d) = "True" and isnumeri+ (d4) = "True"and isnumeri+ (d8) = "True"and isnumeri+ (d9) =
"True"and isnumeri+ (d7) = "True"and isnumeri+ (dB) = "True"and isnumeri+ (dG) = "True"and isnumeri+ (d%0) = "True" Then
msgbox "It is a !umeri+ >aue" ese
:sgbox "It is !T !umeri+" End If
1) Verify weather the entered value is a 18 digit value or not and 9umeric value or not :;sing multiple if conditions)
Dim a&x&y&F&num
num=Inputbox ("Enter a /hone !umber")
d%= eft (num&%) d%0=ight (num&%)
d#=mid (num& #& en (%)) d=mid (num& & en (%)) d4=mid (num& 4& en (%)) d8=mid (num& 8& en (%)) d9=mid (num& 9& en (%)) d7=mid (num& 7& en (%)) dB=mid (num& B& en (%)) dG=mid (num& G& en (%))
If en (num) =%0 Then
If isnumeri+ (d%) = "True" and isnumeri+ (d#) = "True" and isnumeri+ (d) = "True" and isnumeri+ (d4) = "True"and isnumeri+ (d8) = "True"and isnumeri+ (d9) =
"True"and isnumeri+ (d7) = "True"and isnumeri+ (dB) = "True"and isnumeri+ (dG) = "True"and isnumeri+ (d%0) = "True" Then
End If End If
If en (num) < %0 Then
:sgbox "It is !T $aid !umber " End If
*ontrol -low Examples
:;sing *onditional and <oop Statements) 15) &ead a num"er and verify that num"er &ange weather in "etween 1 to 188 or 181 to 1888ption expi+it Dim a&x
a=Inputbox ("Enter a Vaule")
a=+db(a)
If a= %00 Then 3or x= % to %00 If a=x Then
msgbox "a is in bet*een % to %00 range" End If
!ext ese
3or x= %0% to %000 If a=x Then
msgbox "a is in bet*een %0% to %000 range" End If
!ext End If
17) &ead 6ata and find that data si=e# +f si=e >?' then display invalid data message# if data si=e @ ' then verify Aa is there or not in that data
Dim x
x=Inputbox ("Enter 4 digit $aue")
x1=Right(x,1)
x#=Left (x&%) x=mid (x&#&Len(%)) x4=mid (x&&Len(%)) y=en(x) If y=4 ThenIf x%="a" or x#="a" or x="a" or x4="a" Then msgbox "a is there"
ese
msgbox "a is !ot there" End If
ese
End If
!8) -or Each...9ext Statement
epeats a group of statements for ea+h eement in an array or +oe+tion
Dim a&b&x () a=#0 b=0 x(0)= "Hddition is ". ab x(%)="-ubstra+tion is " . aCb x(#)= ":utipi+ation is " . a1b x()= "Di$ision is " . a2b
3or Ea+h eement In x msgbox eement !ext
!1. Given num"er is primw or not
Option explicit
Dim
n, i, ounter
ounter = !
n=
cint
(
inputbox
("enter nuber"))
For
i = 1
To
n
If
n
mod
i = !
Then
ounter = ounter # 1
End If
Next
If
ounter = 2
Then
msgbox
"$rienuber"
Else
msgbox
"%ot$rienuber"
Find the total number of prime numbers for a given Number.
Dim counter,i,j, num,val
num=cint(inputbox("enter value for num"))
for i= 2 to num
for j = 1 to i
if i mod j = 0 Then
counter=counter+1
end if
ext
if counter=2 Then
val=val!pace (2)!i
end if
#ounter=0
ext
$%box val
&Program to check if the given string is a Palindrome or not
$'tr=cae(inputbox("*nter the trin%"))
evtr=trrevere($'tr)
if trcomp($'tr,evtr)=0 then
m%box "-t i a .alindrome"
ele
m%box "-t i not a .alindrome"
end if
rite a b *ript to +i*pla -atorial o- a nuber u*ing -untion
Answer
. 1
sub fact(pnum)
dim vf
vf=1
for i=2 to pnum
vf=vf*i
next
msgbox vf
end sub
call fact(0)
call fact(3)
'Program to reverse a string without using
strreverse
MyStr = inputbox("Enter the String:") nCnt = Len(MyStr) For i = 1 to nCnt RevStr = Mid(MyStr,i,1)&RevStr ext M!gbox RevStr
Fibonacii number
Dim
n
n =
CINT
(
Inputbox
("Enter a range"))
-1=!
-3=-1#-2
ar= -1/","/-2
Do While
-30n
ar = ar/","/-3
-1=-2
-2=-3
-3=-1#-2
loop
MsgBox
ar
.leae find m' code /ith 10 uer and avin% the rder number in m' created xl
'Create excel obj
Set m'xl=createobject("excelapplication" )
m'xlor3boo3pen "#4er4*ael24De3top45li%ht-D"
m'xl6pplication7iible= True
Set m'heet=m'xl6ctiveor3boo3or3heet( "8o%in")
For
i = 1 To 10
.artner-D = m'heetcell(i,"6")7alue
.a/ord = m'heetcell(i,"9")7alue
'Invoke Flight Application
'temutilun "#4.ro%ram 5ile4:.4nified 5unctional
Tetin%4ample4fli%ht4app4fli%ht;aexe"
'Enter Agent Name and Password
Dialo%("8o%in")in*dit("6")Set .artner-D
Dialo%("8o%in")in*dit(".")Set .a/ord
Dialo%("8o%in")in9utton("<")#lic3
'Enter Fly reservation rom to get !rderNo
indo/("5li%ht eervation")inbject("Date of 5li%ht")T'pe "10121"
indo/("5li%ht eervation")in#ombo9ox("5l' 5rom")Select 2
indo/("5li%ht eervation")in#ombo9ox("5l' To")Select >
indo/("5li%ht eervation")in9utton("58-?:T")#lic3
indo/("5li%ht eervation")Dialo%("5li%ht Table")in8it("5rom")Select
indo/("5li%ht eervation")Dialo%("5li%ht Table")in9utton("<")#lic3
indo/("5li%ht eervation")in*dit("ame")Set "6ja'"
indo/("5li%ht eervation")inadio9utton( "5irt")#lic3
indo/("5li%ht eervation")in*dit("Tic3et")Set
indo/("5li%ht eervation")in9utton("-nert rder")#lic3
wait
10
rdero = indo/("5li%ht eervation")in*dit("rder
o")?et.ropert'("text")
Msgbox rdero
m'heetcell(i, "#")7alue = rdero
'Close Application
indo/("5li%ht eervation")#loe
Next
m'xl6ctiveor3boo3ave
m'xl6ctiveor3boo3#loe
m'xl6pplication@uit
Set m'heet = nothing
Set m'xl = nothing
6im a 6im c:188) a @ C13!e%e'r,t/hi5C " @ <en:a) -or i @ 1 to " c:i) @ Did:a#i#1) +f isnumeric:c:i)) hen Dsg"ox c:i) End +f 9extsystemuti?un "iexpore?exe"& "http@22ms+ampaignfa+tory?+om" -et a;ayin5s=des+ription?'reate
a;ayin5s("mi++ass")?>aue = "Lin5"
-et :-L = ro*ser("+reationtime@=0")?/age("tite@=?1")?'hidb;e+ts(a;ayin5s) Tota=:-L?+ount
msgbox Tota
3or i = % To tota step C%
myin5s= :-L(i)?6et/roperty("innertext") /rint myin5s
!ext
1) Verify <ogin Boundary ('he+5 a the boundary +onditions of the Login diaog box? 'he+5s to see if the +orre+t message appears in the error *indo* (3ight eser$ation :essage)
%) Hppi+ationDir = En$ironment("/rodu+tDir")
#) Hppi+ation/ath = "AsampesAfightAappAfight4a?exe" ) If indo*("3ight eser$ation")?Exist(#) Then
4) indo*("3ight eser$ation")?'ose
8) -ystemti?un Hppi+ationDir . Hppi+ation/ath 9) Eseif !ot Diaog("Login")?Exist(%) Then
7) -ystemti?un Hppi+ationDir . Hppi+ation/ath B) End If
G) Diaog("Login")?inEdit("Hgent !ame@")?-et Datatabe?>aue ("Hgent!ame"&dt6oba-heet)
%0) Diaog("Login")?inEdit("/ass*ord@")?-et Datatabe?>aue ("/ass*ord"&dt6oba-heet)
%%) Diaog("Login")?inutton("J")?'i+5
%#) If Diaog("Login")?Diaog("3ight eser$ations")?Exist(%) and Datatabe?>aue ("-tatus"&dt6oba-heet)="3ai" Then
%) Diaog("Login")?Diaog("3ight eser$ations")?-tati+("Hgent name must be at")?'he+5 'he+5/oint("Hgent name must be at east 4 +hara+ters ong?") %4) Diaog("Login")?Diaog("3ight eser$ations")?inutton("J")?'i+5 %8) Eseif indo*("3ight eser$ation")?Exist(%0) and Datatabe?>aue ("-tatus"&dt6oba-heet)="/ass" Then
%9) eporter?eportE$ent /H--&"Login@ "&"-u++eeded" %7) Ese
%B) eporter?eportE$ent 3ai&"Login@ "&"'ombination K" . Datatabe?6et'urrento* . " *as not a++ording to Ex+e fie"
%G) End If
!) Verify *ancel $peration (in Login Diaog box& if user see+ts +an+e button& before enter any data after enter data diaog box shoud be disappeared?)
%) In$o5eappi+ation "'@A/rogram 3iesA:er+ury Intera+ti$eAui+5Test /rofessionaAsampesAfightAappAfight4a?exe"
#) Diaog("Login")?H+ti$ate
) Diaog("Login")?inutton("'an+e")?'i+5 4) If Diaog("Login")?Exist (#) =True Then 8) eporter?eportE$ent %&"sd"&"3ai" 9) Ese
7) eporter?eportE$ent 0&"sd"&"/ass"
B) In$o5eappi+ation "'@A/rogram 3iesA:er+ury Intera+ti$eAui+5Test /rofessionaAsampesAfightAappAfight4a?exe"
G) End If
%0) Diaog("Login")?H+ti$ate
%%) Diaog("Login")?inEdit("Hgent !ame@")?-et "asdf" %#) Diaog("Login")?inutton("'an+e")?'i+5
%) If Diaog("Login")?Exist (#) =True Then %4) eporter?eportE$ent %&"sd"&"3ai" %8) Ese
%9) eporter?eportE$ent 0&"sd"&"/ass"
%7) In$o5eappi+ation "'@A/rogram 3iesA:er+ury Intera+ti$eAui+5Test /rofessionaAsampesAfightAappAfight4a?exe"
%B) End If
%G) Diaog("Login")?H+ti$ate
#0) Diaog("Login")?inEdit("Hgent !ame@")?-et "asdf" #%) Diaog("Login")?inEdit("/ass*ord@")?-et-e+ure "4aGGaf48d+bd809+B48%b#74d#da07bBff88%" ##) Diaog("Login")?inutton("'an+e")?'i+5 #) If Diaog("Login")?Exist (#)=True Then #4) eporter?eportE$ent %&"sd"&"3ai" #8) Ese
#9) eporter?eportE$ent 0&"sd"&"/ass"
#7) In$o5eappi+ation "'@A/rogram 3iesA:er+ury Intera+ti$eAui+5Test /rofessionaAsampesAfightAappAfight4a?exe"
#B) End If
#G) Diaog("Login")?H+ti$ate
0) Diaog("Login")?inEdit("Hgent !ame@")?-et "asdf" %) Diaog("Login")?inEdit("/ass*ord@")?-et-e+ure "4aGGaf48d+bd809+B48%b#74d#da07bBff88%" #) Diaog("Login")?inutton("J")?'i+5
%) Verify ddition# Su"traction# Dultiplication and 6ivision $perations in *alculator pplication. %) Dim aes&ses&des&mes #) >bindo*(">bindo*")?H+ti$ate ) >bindo*(">bindo*")?>bEdit(">bEdit")?-et "%0" 4) >bindo*(">bindo*")?>bEdit(">bEditM#")?-et "#0" 8) $%=>bindo*(">bindo*")?>bEdit(">bEdit")?6et/roperty ("text") 9) $#=>bindo*(">bindo*")?>bEdit(">bEditM#")?6et/roperty ("text") 7) >bindo*(">bindo*")?>button("HDD")?'i+5 B) aes=>bindo*(">bindo*")?>bEdit(">bEditM")?6et>isibeText
G) >bindo*(">bindo*")?>button("-")?'i+5 %0) ses=>bindo*(">bindo*")?>bEdit(">bEditM")?6et>isibeText %%) >bindo*(">bindo*")?>button(":L")?'i+5 %#) mes=>bindo*(">bindo*")?>bEdit(">bEditM")?6et>isibeText %) >bindo*(">bindo*")?>button("DI>")?'i+5 %4) des=>bindo*(">bindo*")?>bEdit(">bEditM")?6et>isibeText %8) $%=+db($%) %9) $#=+db($#) %7) aes=+db (aes) %B) ses=+db (ses) %G) mes=+db (mes) #0) des=+db (des) #%) If aes=$%$# Then
##) eporter?eportE$ent 0&"es"&"Hddition /assed" #) ese
#4) eporter?eportE$ent %&"es"&"Hddition 3aied" #8) End If
#9) If ses=$%C$# Then
#7) eporter?eportE$ent 0&"es"&"-ubtra+tion /assed" #B) ese
#G) eporter?eportE$ent %&"es"&"-ubtra+tion 3aied" 0) End If
%) If mes=$%1$# Then
#) eporter?eportE$ent 0&"es"&":utipe+ation /assed" ) ese
4) eporter?eportE$ent %&"es"&":utipe+ation 3aied" 8) End If
9) If des=$%2$# Then
7) eporter?eportE$ent 0&"es"&"Di$ision /assed" B) ese
G) eporter?eportE$ent %&"es"&"Di$ision 3aied" 40) End If
') Verify state of ;pdate $rder Button# "efore open an $rder and after open an $rder (in 3ight eser$ation before opening an order pdate rder button shoud be disabed after opening an order enabed?)
%) ption expi+it #) Dim bo&ao
) If !ot *indo*("3ight eser$ation")?Exist (#) Then
4) -ystemti?un "'@A/rogram 3iesA:er+ury Intera+ti$eAui+5Test /rofessionaAsampesAfightAappAfight4a?exe"
9) Diaog("Login")?inEdit("Hgent !ame@")?-et "6+reddy" 7) Diaog("Login")?inEdit("/ass*ord@")?-et-e+ure "4aaBb+eGGB4f%a%8ea%B7a#da8b%B+848abb0%+f" B) Diaog("Login")?inutton("J")?'i+5 G) End If %0) indo*("3ight eser$ation")?H+ti$ate
%%) bo=indo*("3ight eser$ation")?inutton("pdate rder")?6et/roperty ("Enabed")
%#) indo*("3ight eser$ation")?inutton("utton")?'i+5
%) indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("rder !o?")?-et "!"
%4) indo*("3ight eser$ation")?Diaog("pen rder")?inEdit("Edit")?-et "%" %8) indo*("3ight eser$ation")?Diaog("pen rder")?inutton("J")?'i+5 %9) ao=indo*("3ight eser$ation")?inutton("pdate rder")?6et/roperty ("Enabed")
%7) If bo=3ase Then
%B) eporter?eportE$ent 0&"es"&"pdate rder utton Disabed" %G) ese
#0) eporter?eportE$ent %&"es"&"pdate rder utton Enabed" #%) End If
##) If ao=True Then
#) eporter?eportE$ent 0&"es"&"pdate rder utton Enabed" #4) ese
#8) eporter?eportE$ent %&"es"&"pdate rder utton Disabed" #9) End If
,) (rice *onsistency# +n -light &eservation (In 3ight eser$ation& 3irst +ass pri+e=1E+onomy +ass pri+e and usiness +ass pri+e=#1E+onomy +ass pri+e) %) ption expi+it
#) Dim n&f&b&e
) If !ot *indo*("3ight eser$ation")?Exist (#) Then
4) -ystemti?un "'@A/rogram 3iesA:er+ury Intera+ti$eAui+5Test /rofessionaAsampesAfightAappAfight4a?exe"
8) Diaog("Login")?H+ti$ate
9) Diaog("Login")?inEdit("Hgent !ame@")?-et "asdf" 7) Diaog("Login")?inEdit("/ass*ord@")?-et-e+ure "4aaBb7b7+8B#9B0+f+b#4d07%4+Gbbf0dff%eb" B) Diaog("Login")?inutton("J")?'i+5 G) End If %0) 3or n= % to %0 step % %%) indo*("3ight eser$ation")?H+ti$ate %#) indo*("3ight eser$ation")?inutton("utton")?'i+5
%) indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("rder !o?")?-et "!"
%4) indo*("3ight eser$ation")?Diaog("pen rder")?inEdit("Edit")?-et n %8) indo*("3ight eser$ation")?Diaog("pen rder")?inutton("J")?'i+5 %9) indo*("3ight eser$ation")?inadioutton("3irst")?-et %7) f=indo*("3ight eser$ation")?inEdit("/ri+e@")?6et>isibeText %B) indo*("3ight eser$ation")?inadioutton("usiness")?-et %G) b=indo*("3ight eser$ation")?inEdit("/ri+e@")?6et>isibeText #0) indo*("3ight eser$ation")?inadioutton("E+onomy")?-et #%) e=indo*("3ight eser$ation")?inEdit("/ri+e@")?6et>isibeText ##) f=+db(mid(f&#&en (fC%))) #) b=+db(mid(b&#&en (bC%))) #4) e=+db(mid(e&#&en (eC%))) #8) If f=1e and b=#1e Then
#9) eporter?eportE$ent 0&"es"&"/ri+y 'onsistan+y is there" #7) ese
#B) eporter?eportE$ent %&"es"&"/ri+y 'onsistan+y is !T there" #G) End If
0) indo*("3ight eser$ation")?inutton("uttonM#")?'i+5 %) indo*("3ight eser$ation")?Diaog("3ight
eser$ations")?inutton("!o")?'i+5 #) !ext
/) Verify otal# +n -light &eservation (In 3ight eser$ation& Tota = Ti+5ets 1 /ri+e)
%) ption Expi+it #) Dim t&p&tot&n
) 3or n= % to %0 step %
4) If !ot *indo*("3ight eser$ation")?Exist (#) Then
8) -ystemti?un "'@A/rogram 3iesA:er+ury Intera+ti$eAui+5Test
/rofessionaAsampesAfightAappAfight4a?exe"&""&"'@A/rogram 3iesA:er+ury Intera+ti$eAui+5Test /rofessionaAsampesAfightAappA"&"open"
9) Diaog("Login")?H+ti$ate
7) Diaog("Login")?inEdit("Hgent !ame@")?-et "6+reddy" B) Diaog("Login")?inEdit("/ass*ord@")?-et-e+ure "4aaBG#d9#+8#Gf%+##GB%78ad7B+8Bf4daBe4" G) Diaog("Login")?inutton("J")?'i+5 %0) End If %%) indo*("3ight eser$ation")?H+ti$ate %#) indo*("3ight eser$ation")?inutton("utton")?'i+5
%) indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("rder !o?")?-et "!"
%4) indo*("3ight eser$ation")?Diaog("pen rder")?inEdit("Edit")?-et n %8) indo*("3ight eser$ation")?Diaog("pen rder")?inutton("J")?'i+5 %9) t=indo*("3ight eser$ation")?inEdit("Ti+5ets@")?6et>isibeText %7) p=indo*("3ight eser$ation")?inEdit("/ri+e@")?6et>isibeText %B) tot=indo*("3ight eser$ation")?inEdit("Tota@")?6et>isibeText %G) t=+db (t) #0) p='db(mid(p&#&en (pC%))) #%) tot='db(mid(tot&#&en (totC%))) ##) If tot=t1p Then
#) eporter?eportE$ent 0&"es"&"'a+uation /assed" #4) ese
#8) eporter?eportE$ent %&"es"&"'a+uation 3aied" #9) End If
#7) !ext
) Verify -light -rom -light o *om"o Boxes (In 3ight reser$ation& see+t an item from 3y 3rom@ +ombo box and $erify *eather that item a$aiabe or not in 3y To@ +ombo box& i5e this see+t a items one by one in 3y 3rom and $erify *eather see+ted items a$aiabe or not in 3y To?)
%) ption expi+it
#) Dim ,tp&fightMapp&f&t&i&;&x&y
) If !ot indo*("text@=3ight eser$ation")?Exist (7)= True Then 4) T/=En$ironment("/rodu+tDir")
8) 3ightMapp="AsampesAfightAappAfight4a?exe" 9) -ystemti?un T/ . 3ightMapp
7) Diaog("text@=Login")?H+ti$ate
B) Diaog("text@=Login")?inEdit("atta+hed text@=Hgent !ame@")?-et "asdf" G) Diaog("text@=Login")?inEdit("atta+hed text@=/ass*ord@")?-et-e+ure "4aa8eddaf9B0e7a78Gbee%+84%GGda84a8b98"
%0) Diaog("text@=Login")?inutton("text@=J")?'i+5 %%) End If
%#) indo*("text@=3ight eser$ation")?H+ti$ate
%) indo*("text@=3ight eser$ation")?inutton("*indo* id@=9")?'i+5
%4) indo*("text@=3ight eser$ation")?H+ti$eN("a+xMname@=:as5Edox"&"*indo* id@=0")?Type "0G0G%0"
%8) f=indo*("text@=3ight eser$ation")?in'omboox("atta+hed text@=3y 3rom@")?6etItems'ount
%9) 3or i= 0 to fC% step %
%7) indo*("text@=3ight eser$ation")?in'omboox("atta+hed text@=3y 3rom@")?-ee+t (i)
%B) x=indo*("text@=3ight eser$ation")?in'omboox("atta+hed text@=3y 3rom@")?6et/roperty ("text")
%G) t=indo*("text@=3ight eser$ation")?in'omboox("atta+hed text@=3y To@"&"x@=#44"&"y@=%47")?6etItems'ount
#0) 3or ;= 0 to tC% step %
#%) indo*("text@=3ight eser$ation")?in'omboox("atta+hed text@=3y To@"&"x@=#44"&"y@=%47")?-ee+t (;)
##) y=indo*("text@=3ight eser$ation")?in'omboox("atta+hed text@=3y To@"&"x@=#44"&"y@=%47")?6et/roperty ("text")
#) If x < y Then
#4) eporter?eportE$ent 0&"es"&"Test /assed" #8) Ese
#9) eporter?eportE$ent %&"es"&"Test 3aied" #7) End If
#B) !ext #G) !ext
5) Verify $rder 9o Entry in -light &eservation. (In pen rder diaog box& rder !o ob;e+t a++epts numeri+ $aues ony?)
%) If !ot *indo*("3ight eser$ation")?Exist (#) Then
#) -ystemti?un "'@A/rogram 3iesA:er+ury Intera+ti$eAui+5Test /rofessionaAsampesAfightAappAfight4a?exe"
) Diaog("Login")?H+ti$ate
4) Diaog("Login")?inEdit("Hgent !ame@")?-et "asdf" 8) Diaog("Login")?inEdit("/ass*ord@")?-et-e+ure "4aaG++aebb00G9#b47ff7fb0+e8#4+%dBB+b4" 9) Diaog("Login")?inutton("J")?'i+5 7) End If B) indo*("3ight eser$ation")?H+ti$ate G) indo*("3ight eser$ation")?inutton("utton")?'i+5
%0) indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("rder !o?")?-et "!"
%%) indo*("3ight eser$ation")?Diaog("pen rder")?inEdit("Edit")?-et "a" %#) ord=indo*("3ight eser$ation")?Diaog("pen
rder")?inEdit("Edit")?6et>isibeText %) If ord= "a" Then
%4) eporter?eportE$ent %&"es"&"rder !o b;e+t is ta5ing in$aid data" %8) ese
%9) indo*("3ight eser$ation")?Diaog("pen rder")?inEdit("Edit")?-et "%" %7) indo*("3ight eser$ation")?Diaog("pen rder")?inutton("J")?'i+5 %B) End If
7) Get est 6ata from a -lat file and use in 6ata 6riven esting :through Scripting)
%) Dim fso&myfie
#) -et fso=+reateob;e+t("s+ripting?fiesystemob;e+t") ) -et myfie= fso?opentextfie ("3@Ag+r?txt"&%)
4) myfie?s5ipine
8) hie myfie?atendofine < True 9) x=myfie?readine
7) s=spit (x& "&")
B) -ystemti?un "'@A/rogram 3iesA:er+ury Intera+ti$eAui+5Test /rofessionaAsampesAfightAappAfight4a?exe" G) Diaog("Login")?H+ti$ate %0) Diaog("Login")?inEdit("Hgent !ame@")?-et s(0) %%) Diaog("Login")?inEdit("/ass*ord@")?-et-e+ure s(%) %#) Diaog("Login")?inutton("J")?'i+5 %) indo*("3ight eser$ation")?'ose %4) end
18) *ount# how many Buttons and Edit "oxes availa"le in -light &eservation main window.
%) If !ot *indo*("3ight eser$ation")?Exist (#) Then
#) -ystemti?un "'@A/rogram 3iesA:er+ury Intera+ti$eAui+5Test /rofessionaAsampesAfightAappAfight4a?exe"
) Diaog("Login")?H+ti$ate
4) Diaog("Login")?inEdit("Hgent !ame@")?-et "6+reddy" 8) Diaog("Login")?inEdit("/ass*ord@")?-et "mer+ury" 9) Diaog("Login")?inutton("J")?'i+5
7) End If
B) -et oDes+ = Des+ription?'reate()
G) oDes+("mi++ass")?>aue = "inutton"
%0) -et uttons = indo*("text@=3ight eser$ation")?'hidb;e+ts (oDes+) %%) !umMuttons = uttons?'ount()
%#) -et oDes+%=Des+ription?'reate() %) oDes+%("mi++ass")?>aue="inEdit"
%4) -et Editboxes=indo*("text@=3ight eser$ation")?'hidb;e+ts (oDes+%) %8) !umMEditboxes= editboxes?+ount ()
%9) sum= !umMuttons!umMEditboxes
%7) eporter?eportE$ent #& "es"&"Tota uttons@ ". !umMuttons ."Tota Edit boxes@ ". !umMEditboxes
11) Verify search options in $pen $rder 6ialog "ox
Hfter see+ting rder !o option& other options shoud be disabed&
Hfter see+ting 'ustomer !ame& 3ight date option enabed and rder !o disabed Hfter see+ting 3ight date option& 'ustomer !ame enabed and rder !o disabed)
%) If !ot *indo*("3ight eser$ation")?Exist (#) Then
#) -ystemti?un "'@A/rogram 3iesA:er+ury Intera+ti$eAui+5Test /rofessionaAsampesAfightAappAfight4a?exe"
) Diaog("Login")?H+ti$ate
4) Diaog("Login")?inEdit("Hgent !ame@")?-et "6+reddy" 8) Diaog("Login")?inEdit("/ass*ord@")?-et-e+ure "4aaGed#8b+0ebde99ed7#9adB7d7eGG%47dBbG+" 9) Diaog("Login")?inutton("J")?'i+5 7) End If B) indo*("3ight eser$ation")?H+ti$ate G) indo*("3ight eser$ation")?inutton("utton")?'i+5 %0) indo*("3ight eser$ation")?Diaog("pen rder")?H+ti$ate
%%) oe=indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("rder !o?")?6et/roperty ("Enabed")
%#) +e=indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("'ustomer !ame")?6et/roperty ("Enabed")
%) fe=indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("3ight Date")?6et/roperty("Enabed")
%4) o+=indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("rder !o?")?6et/roperty ("'he+5ed")
%8) ++=indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("'ustomer !ame")?6et/roperty ("'he+5ed")
%9) f+=indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("3ight Date")?6et/roperty("'he+5ed")
%7) If (oe=true and +e=true and fe=true) and (o+="33" and ++="33" and f+="33") Then
%B) eporter?eportE$ent 0&"es"&"/ass" %G) ese
#0) eporter?eportE$ent %&"es"&"3ai" #%) End If
##) indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("rder !o?")?-et "!"
#) ono=indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("rder !o?")?6et/roperty ("'he+5ed")
#4) If ono="!" Then
#8) fd=indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("3ight Date")?6et/roperty ("Enabed")
#9) ono=indo*("3ight eser$ation")?Diaog("pen
#7) fd=fase #B) ono=fase #G) eporter?eportE$ent 0&"es"&"/ass" 0) ese %) eporter?eportE$ent %&"es"&"3ai" #) End If
) indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("rder !o?")?-et "33"
4) indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("'ustomer !ame")?-et "!"
8) +n=indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("'ustomer !ame")?6et/roperty ("'he+5ed")
9) If +n="!" Then
7) ono=indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("rder !o?")?6et/roperty ("Enabed")
B) fd=indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("3ight Date")?6et/roperty ("Enabed") G) fd=True 40) ono=fase 4%) eporter?eportE$ent 0&"es"&"/ass" 4#) ese 4) eporter?eportE$ent %&"es"&"3ai" 44) End If
48) indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("'ustomer !ame")?-et "33"
49) indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("3ight Date")?-et "!"
47) fd=indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("3ight Date")?6et/roperty ("'he+5ed")
4B) If fd="!" Then
4G) ono=indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("rder !o?")?6et/roperty ("Enabed")
80) +n=indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("'ustomer !ame")?6et/roperty ("Enabed") 8%) +n=True 8#) ono=fase 8) eporter?eportE$ent 0&"es"&"/ass" 84) ese 88) eporter?eportE$ent %&"es"&"3ai" 89) End If
1!) +n <ogin 6ialog "ox# Verify Felp message (The message is OThe pass*ord is :E'Y)
%) If !ot Diaog("Login")?Exist (#) Then
#) -ystemti?un "'@A/rogram 3iesA:er+ury Intera+ti$eAui+5Test /rofessionaAsampesAfightAappAfight4a?exe"
) End If
4) Diaog("Login")?H+ti$ate
8) Diaog("Login")?inutton("Pep")?'i+5
9) message=Diaog("Login")?Diaog("3ight eser$ations")?-tati+("The pass*ord is :E'Y")?6et/roperty("text")
7) If message="The pass*ord is :E'Y" Then
B) eporter?eportE$ent 0&"es"&"'orre+t message ".message G) ese
%0) eporter?eportE$ent %&"es"&"orng message " %%) End If
File System Scripts
1) &ead *ontent from a text file and Write in another text file
Dim ob;3so& my3ie%& my3ie#& x
-et ob;3so=+reateob;e+t("-+ripting?3iesystemob;e+t")
-et my3ie%=ob;3so?opentextfie("'@ADo+uments and
-ettingsAg+rADes5topAg+reddy?txt"&%)
-et my3ie#=ob;3so?+reatetextfie("'@ADo+uments and
-ettingsAg+rADes5topAg+r,tp?txt"&%)
Do nti my3ie%?HtEndf-tream=True
x=my3ie%?eadine
my3ie#?riteine x
Loop
my3ie%?'ose
my3ie#?'ose
-et ob;3so=!othing
!) &ead 9um"ers only from a text file and export to another
text file
Dim ob;3so& ob;Text-tream
,myText& x
set ob;3so=+reateob;e+t("-+ripting?3iesystemob;e+t")
-ettingsAg+rADes5topAg+reddy?txt"&%)
-et ob;Text-tream#=ob;3so?opentextfie("'@ADo+uments and
-ettingsAg+rADes5topAg+r,tp?txt"&#)
ob;Text-tream#?riteLine "!umbers"
ob;Text-tream#?riteLine "CCCCCCCCC"
Do nti ob;Text-tream?HtEndf-tream
myText=ob;Text-tream?eadLine
x=spit(myText&" ")
3or i=bound(x) to ubound(x)
If isnumeri+(x(i)) =True Then
ob;Text-tream#?riteLine x(i)
End if
!ext
Loop
ob;Text-tream?'ose
ob;Text-tream#?'ose
-et ob;3so=!othing
%) *ount <ines in a ext -ile
Dim ob;3so& ob;Textstream& Line'ount
-et ob;3so='reateb;e+t("-+ripting?fiesystemob;e+t")
-et ob;Textstream=ob;3so?penText3ie("'@ADo+uments and
-ettingsAg+rADes5topAab+?txt")
Do hie !ot ob;Textstream?HtEndf-tream
Line'ount = Line'ount %
ob;Textstream?eadLine
Loop
:sgbox Line'ount
ob;Textstream?'ose
-et ob;Textstream=!othing
-et ob;3so=!othing
! "reate a Folder
ption *xplicit
Dim obj5, obj5older, trDirector' trDirector' = "D4?credd'"
et obj5 = #reatebject("criptin%5ile'tembject") et obj5older = obj5#reate5older(trDirector')
#! $elete a Folder
et o5 = #reatebject("criptin%5ile'tembject") o5Delete5older("*4?credd'")
%! "op&ing Folders
et o5=createobject("criptin%5ile'temobject") o5#op'5older "*4%cr", "#4jvr", True
'! "hecking weather the folder available or not( if not creating the folder
ption *xplicit
Dim obj5, obj5older, trDirector' trDirector' = "D4?credd'"
et obj5 = #reatebject("criptin%5ile'tembject") -f obj55older*xit(trDirector') Then
et obj5older = obj5?et5older(trDirector') m%box trDirector' ! " alread' created " ele
et obj5older = obj5#reate5older(trDirector') end if
)! *eturning a collection of $isk $rives
et o5 = #reatebject("criptin%5ile'tembject") et colDrive = o5Drive
5or *ach oDrive in colDrive
$%9ox "Drive letter " ! oDriveDrive8etter ext
+! ,etting available space on a $isk $rive
et o5 = #reatebject("criptin%5ile'tembject") et oDrive = o5?etDrive("#")
$%9ox "6vailable pace " ! oDrive6vailablepace
Flat File Scripts
*omputer -ile System
It is a feature of the perating -ystem& used to 'reate2:odify2$ie*2deete Dri$es& 3oders and 3ies
$S 6istri"ution
perating -ystem and ther tiities
-ileSystem$"2ect
>-+ript has /ro$ided -ileSystem$"2ect to perform fie system operations through s+ripting
Dim ob;3so
'reating an Hutomation b;e+t in 3ie -ystem +ass& that +an be used to perform perations on 'omputer 3ie -ystem
-et ob;3so='reateb;e+t("s+ripting?3ie-ystemb;e+t") 1) *reating a -ile Dim ob;3so -et ob;3so='reateb;e+t("s+ripting?3ie-ystemb;e+t") ob;3so?'reateText3ie ("E@A6+reddy?txt") ob;3so?'reateText3ie ("E@A6+reddy?do+") ob;3so?'reateText3ie ("E@A6+reddy?xs") ob;3so?'reateText3ie ("E@A6+reddy?pdf")
9oteH e +an 'reate other fies aso& but they a+t as Text23at 3ies -et ob;3ie = ob;3-?'reateText3ie("E@A6+reddy?txt")
!) *hec3ing weather the -ile is availa"le or not# if not creating the -ile
strDire+tory="E@A" str3ie="6+reddy?txt"
-et ob;3- = 'reateb;e+t("-+ripting?3ie-ystemb;e+t") If ob;3-?3ieExists(strDire+tory . str3ie) Then
-et ob;3oder = ob;3-?6et3oder(strDire+tory) Ese
-et ob;3ie = ob;3-?'reateText3ie("E@A6+reddy?txt") End if
%) &eading 6ata character "y character from a -lat -ile
-et ob;3- = 'reateb;e+t("-+ripting?3ie-ystemb;e+t") -et ob;3ie = ob;3-?penText3ie("E@A6+reddy?txt"& %) Do nti ob;3ie?HtEndf-tream
str'hara+ters = ob;3ie?ead(%) msgbox str'hara+ters
Loop
') &eading 6ata line "y line from a -lat -ile
-et ob;3- = 'reateb;e+t("-+ripting?3ie-ystemb;e+t") -et ob;3ie = ob;3-?penText3ie("E@A6+reddy?txt"& %) Do nti ob;3ie?HtEndf-tream
str'hara+ters = ob;3ie?eadine msgbox str'hara+ters
Loop
,) 6ata 6riven esting "y fetching est data directly from a ext file.
11111111111111111111111111111111111111111111111111
est &eIuirementH Data Dri$en Testing by 3et+hing Test data
dire+ty from a Text fie?
uthorH 6 ' eddy
Date of 'reation@ %C0BC#0%0
(re0reIuisitesH
g+r?txt (Test Data)
est -lowH
'reating an Hutomation b;e+t in 3ie-ystem +ass
pening the Externa Test Data fie using the b;e+t
ead the Data . -pit the Data
6enerating the Login peration
/ass /arameters
1111111111111111111111111111111111111111111111111
Dim ob;3so& my3ie& myLine& my3ied
-et ob;3so='reateb;e+t("-+ripting?3ie-ystemb;e+t")
-et my3ie=ob;3so?penText3ie("'@ADo+uments and
-ettingsAg+r?6''CGH%#3DDGADes5topA$indod?txt"&%) % for ead&
#Crite . BCHppend
my3ie?-5ipLine
Do nti my3ie?HtEndf-tream
myLine=my3ie?eadLine
my3ied=-pit(myLine&"&")
-ystemti?un "'@A/rogram 3iesAP/Aui+5Test
/rofessionaAsampesAfightAappAfight4a?exe"
Diaog("text@=Login")?H+ti$ate
Diaog("text@=Login")?inEdit("atta+hed text@=Hgent !ame@")?-et
my3ied(0)
Diaog("text@=Login")?inEdit("atta+hed text@=/ass*ord@")?-et
my3ied(%)
*ait #
Diaog("text@=Login")?inutton("text@=J")?'i+5
indo*("text@=3ight eser$ation")?'ose
Loop
my3ie?'ose
-et ob;3so=!othing
/) Writing data to a text file
Dim -tuff& my3-& rite-tuff& date-tamp date-tamp = Date()
-tuff = "I am /reparing this s+ript@ " .date-tamp
-et my3- = 'reateb;e+t("-+ripting?3ie-ystemb;e+t")
-et rite-tuff = my3-?penText3ie("e@A6+reddy?txt"& B& True) rite-tuff?riteLine(-tuff)
rite-tuff?'ose
-ET rite-tuff = !TPI!6 -ET my3- = !TPI!6
) 6elete a text file
-et txt3iepath = ob;3-?6et3ie("E@Ag+r?txt") txt3iepath?Deete()
5) *hec3ing weather the -ile is availa"le or not# if availa"le delete the -ile
strDire+tory="E@A" str3ie="g+r?txt"
-et ob;3- = 'reateb;e+t("-+ripting?3ie-ystemb;e+t") If ob;3-?3ieExists(strDire+tory . str3ie) Then
-et ob;3ie = ob;3-?6etfie(strDire+tory . str3ie) ob;3ie?deete ()
End if
7) *omparing two text files
Dim f%& f#
f%="e@A6+reddy%?txt" f#="e@A6+reddy#?txt"
/ubi+ 3un+tion 'ompare3ies (3ie/ath%& 3ie/ath#) Dim 3-& 3ie%& 3ie#
-et 3- = 'reateb;e+t("-+ripting?3ie-ystemb;e+t")
If 3-?6et3ie(3ie/ath%)?-iFe < 3-?6et3ie(3ie/ath#)?-iFe Then 'ompare3ies = True
Exit 3un+tion End If
-et 3ie% = 3-?6et3ie(3ie/ath%)?penHsText-tream(%& 0) -et 3ie# = 3-?6et3ie(3ie/ath#)?penHsText-tream(%& 0) 'ompare3ies = 3ase
Do hie 3ie%?HtEndf-tream = 3ase -tr% = 3ie%?ead
-tr# = 3ie#?ead
'ompare3ies = -tr'omp(-tr%& -tr#& 0) If 'ompare3ies < 0 Then 'ompare3ies = True Exit Do End If Loop 3ie%?'ose() 3ie#?'ose() End 3un+tion 'a 'omparefies(f%&f#)
If 'ompare3ies(f%& f#) = 3ase Then :sgox "3ies are identi+a?"
Ese
:sgox "3ies are different?" End If
18) *ounting the num"er of times a word appears in a file
s3ie!ame="E@Ag+r?txt" s-tring="g+reddy"
'onst 3MEHDI!6 = %
Dim o3so& oTxt3ie& seadTxt& oegEx& o:at+hes
-et o3so = 'reateb;e+t("-+ripting?3ie-ystemb;e+t")
-et oTxt3ie = o3so?penText3ie(s3ie!ame& 3MEHDI!6) seadTxt = oTxt3ie?eadH
-et oegEx = !e* egExp oegEx?/attern = s-tring
oegEx?Ignore'ase = bIgnore'ase oegEx?6oba = True
-et o:at+hes = oegEx?Exe+ute(seadTxt) :at+hes3ound = o:at+hes?'ount
-et oTxt3ie = !othing @ -et o3so = !othing @ -et oegEx = !othing msgbox :at+hes3ound
11) &ead a *SV -ile ;sing 6ata"ase echniIues
n Error esume !ext
'onst adpen-tati+ = 'onst adLo+5ptimisti+ = 'onst ad'mdText = .P000%
-et ob;'onne+tion = 'reateb;e+t("HDD?'onne+tion") -et ob;e+ord-et = 'reateb;e+t("HDD?e+ordset")
str/athtoText3ie = "'@ADatabasesA"
ob;'onne+tion?pen "/ro$ider=:i+rosoft?Qet?LED?4?0R" . M "Data -our+e=" . str/athtoText3ie . "R" . M
"Extended /roperties=""textRPD=YE-R3:T=Deimited"""
ob;e+ordset?pen "-ELE'T 1 3: /honeList?+s$"& M
ob;'onne+tion& adpen-tati+& adLo+5ptimisti+& ad'mdText
s+ript?E+ho "!ame@ " . ob;e+ordset?3ieds?Item("!ame") s+ript?E+ho "Department@ " . M
ob;e+ordset?3ieds?Item("Department")
s+ript?E+ho "Extension@ " . ob;e+ordset?3ieds?Item("Extension") ob;e+ordset?:o$e!ext
Loop
1!) &ead a ext -ile into an rray
'onst 3oreading = %
-et ob;3- = 'reateb;e+t("-+ripting?3ie-ystemb;e+t") -et ob;Text3ie = ob;3-?penText3ie M
("e@Ag+reddy?txt"& 3oreading)
Do nti ob;Text3ie?HtEndf-tream str!extLine = ob;Text3ie?eadine arr-er$i+eList = -pit(str!extLine & "&")
s+ript?E+ho "-er$er name@ " . arr-er$i+eList(0) 3or i = % to bound(arr-er$i+eList)
s+ript?E+ho "-er$i+e@ " . arr-er$i+eList(i) !ext
Loop
1%) *alculate si=e of a ext file
Dim ob;3so& 3ie%&3ie#
3ie%="'@ADo+uments and -ettingsA% I6PHTHYADes5topAxyF?txt" -et ob;3so='reateb;e+t("
-+ripting?3ie-ystemb;e+t") x= ob;3so?6et3ie(3ie%)?-iFe :sgbox x. " ytes"
1') est &eIuirementH $pen 1 to 18 orders in -light &eservation # *apture *ustomer names and Export into a ext file
Test 3o*@
Login peration
pen rder peration and form the Loop to open % to %0 rders 'apture 'usomer names using 6et/roperty :ethod
'reate 3ie system b;e+t and pen the Text fie using the b;e+t and Export 'usomer names
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC ption Expi+it
Dim rderM!umber& 'ustomerM!ame& ob;3so& my3ie -et ob;3so='reateb;e+t("-+ripting?3ie-ystemb;e+t")
-et my3ie= ob;3so?'reateText3ie ("'@ADo+uments and -ettingsA% I6PHTHYADes5topAab+!e*?txt"&#)
my3ie?riteLine "'usomer !ames" my3ie?riteLine "CCCCCCCCCCCCCCCCCCCC"
If !ot indo*("3ight eser$ation")?Exist() Then -ystemti?un "'@A/rogram 3iesAP/Aui+5Test
/rofessionaAsampesAfightAappAfight4a?exe"&""&"'@A/rogram 3iesAP/Aui+5Test /rofessionaAsampesAfightAappA"&"open"
Diaog("Login")?H+ti$ate
Diaog("Login")?inEdit("Hgent !ame@")?-et "asdf" Diaog("Login")?inEdit("/ass*ord@")?-et-e+ure "4+4B8G0B70499bBd+080bbd#4eB%9BG0+747++fB" Diaog("Login")?inutton("J")?'i+5
End If
3or rderM!umber= % to %0 step % indo*("3ight eser$ation")?H+ti$ate
indo*("3ight eser$ation")?inutton("utton")?'i+5
indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("rder !o?")?-et "!"
indo*("3ight eser$ation")?Diaog("pen rder")?inEdit("Edit")?-et rderM!umber
indo*("3ight eser$ation")?Diaog("pen rder")?inutton("J")?'i+5 'ustomerM!ame = indo*("3ight eser$ation")?inEdit("!ame@")?6et/roperty("text") *ait (#) my3ie?riteLine 'ustomerM!ame !ext my3ie?'ose -et ob;3so=!othing %8) 111111111111111111111111111111111111111111111111111111
est &eIuirementH *apturing all Buttons 9ames from the <ogin 6ialog "ox and exporting to a ext file
Huthor@ G * &eddy
Date of 'reation@ %C0BC#0%0
(re0reIuasitesH g+r?txt
est -lowH
'reating an Hutomation b;e+t in 3ie-ystem +ass pening the Externa Test Data fie using the b;e+t
'reating 'oe+tion ob;e+t and 'apturing utton !ames using the b;e+t riting utton !ames to an Externa Text fie
11111111111111111111111111111111111111111111111111111111
Dim ob;3so& my3ie& outton& uttons& Totuttons
-et ob;3so='reateb;e+t("-+ripting?3ie-ystemb;e+t")
-et my3ie=ob;3so?penText3ie("'@ADo+uments and -ettingsAg+r?6''C GH%#3DDGADes5topA$indod?txt"&#) % for ead& #Crite . BCHppend my3ie?riteLine "utton !ames"
-et outton=Des+ription?'reate
outton("mi++ass")?$aue="inutton"
-ystemti?un "'@A/rogram 3iesAP/Aui+5Test /rofessionaAsampesAfightAappAfight4a?exe" -et uttons=Diaog("text@=Login")?'hidb;e+ts(outton) Totuttons=uttons?'ount 3or i= 0 to TotuttonsC% myutton=uttons(i)?6eto/roperty("text") my3ie?riteLine myutton !ext my3ie?'ose -et ob;3so=!othing
1/) 6elete a ext file if it is an empty file
Dim ob;3so& 3ie/ath
3ie/ath="'@ADo+uments and -ettingsAg+reddyADes5topAab+?txt" -et ob;3so='reateb;e+t("-+ripting?3ie-ystemb;e+t") 3ie-iFe=ob;3so?6et3ie(3ie/ath)?-iFe :sgbox 3ie-iFe If 3ie-iFe=0 Then ob;3so?Deete3ie(3ie/ath) End If -et ob;3so=!othing
6BSE *$99E*+$9
et dbcon = createobject("6DD9connection")
dbconpen
"D=$aterAmonitroA220B-D=aB.D=Cualit'B6..=@uic3Tet
.rofeionalB-D=BD6T696*=materB86?6?*=uAen%lih"
m%box dbcontate
&et ocmd = createobject("6DD9command")
&
ocmd6ctive#onnection = dbcon
&
ocmd#ommandText = "Cl Cuer'"
&
ocmd*xecute
et r = #reateobject("6DD9ecordet")
rpen "elect E from dboptAmonitor",dbcon
columencount = r5ield#ount
columnname = r5ield(0)ame!vbtab!r5ield(1)ame
Do /hile r*5 FG True
r$ove5irt
datavalue = r5ield(0)7alue!vbtab!r5ield(1)7alue
r$oveext
8oop
et r = nothin%
et dbcon = nothin%
ript to inoe the light Re*eration ppliation heing hether a login *reen i* opene+ If Notialog("8ogin")9Exi*t(!) Then
pp:$ath = ";<$rogra ile*<erur Interatie<>ui?e*t $ro-e**ional<*aple*<-light<app<-light4a9exe"
In!o"eApplic#tion pp:$ath En+ I-
ript to login in to the ppliation ialog("8ogin")9tiate
ialog("8ogin")9@inE+it("gent %ae;")9$et "?e*tu*er" ialog("8ogin")9@inE+it("$a**or+;")9$et "erur" ialog("8ogin")9@inAutton("BC")9li
ript to in*ert an or+er an+ print the Br+er %uber @in+o("light Re*eration")9tiate
@in+o("light Re*eration")9@inAutton("%e")9li
@in+o("light Re*eration")9@inBbDet("ate o- light;")9T%pe "121212" @in+o("light Re*eration")9@inoboAox("l ro;")9$elect "ran-urt" @in+o("light Re*eration")9@inoboAox("l ?o;")9$elect "8o* ngele*" @in+o("light Re*eration")9@inAutton("8IF?")9li
@in+o("light Re*eration")9ialog("light* ?able")9@inAutton("BC")9li @in+o("light Re*eration")9@inE+it("%ae;")9$et "?e*t u*er"
@in+o("light Re*eration")9@inAutton("In*ert Br+er")9li W#it&
Br+:%u = @in+o("light Re*eration")9@inE+it("Br+er %o;")9etRo$ropert( "text") *gbox "?he Br+er %uber i*; "/Br+:%u
ript to Bpen an Exi*ting Br+er
Fere e ill a**ue that the or+er i* alrea+ in*erte+ @in+o("light Re*eration")9tiate
@in+o("light Re*eration")9ialog( "Bpen Br+er")9@inheAox("he or+er")9$et "B%"
@in+o("light Re*eration")9ialog("Bpen Br+er")9@inE+it("Br+er %uber")9$et Br+:%u
@in+o("light Re*eration")9ialog("Bpen Br+er")9@inAutton("BC")9li ript to up+ate an exi*ting or+er
@in+o("light Re*eration")9tiate
@in+o("light Re*eration")9@inBbDet("ate o- light;")9T%pe "111111" @in+o("light Re*eration")9@inoboAox("l ro;")9$elect "8o* ngele*" @in+o("light Re*eration")9@inoboAox("l ?o;")9$elect "ran-urt" @in+o("light Re*eration")9@inAutton("8IF?")9li
@in+o("light Re*eration")9ialog("light* ?able")9@inAutton("BC")9li @in+o("light Re*eration")9@inE+it("%ae;")9$et "?e*t G*er 1"
@in+o("light Re*eration")9@inAutton("Gp+ate Br+er")9li ript to lo*e the ppliation
@in+o("light Re*eration")9Close
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& &&&&&&&&&&&&&&
ript to in*ert an or+er -ro external *prea+*heet
$opulate the +ata into the global*heet, +e-ine the +atatable iteration* u*ing *ript an+ exeute the in*ertor+er
et the +atatable iteration* un+er te*t *etting* to Run one iteration onl
tep1; Iport the +ata into the Runtie +atatable ata?able9Iport("E;<In*ert Br+er19xl*")
tep 2; et the roount an+ *tore it in a ariable alle+ roount roount = ata?able9etRoount()
For i = 1 to roount
tep 4; et the urrent ro a* the atie ro ata?able9eturrentRo(i)
tep 5; In*ert or+er *ript ith appropriate paraeter* @in+o("light Re*eration")9tiate
@in+o("light Re*eration")9@inAutton("%e")9li
@in+o("light Re*eration")9@inBbDet("ate o- light;")9T%pe ata?able9'#lue(1,1) @in+o("light Re*eration")9@inoboAox("l ro;")9$elect ata?able9'#lue(2,1) @in+o("light Re*eration")9@inoboAox("l ?o;")9$elect ata?able9'#lue(3,1) @in+o("light Re*eration")9@inAutton("8IF?")9li
@in+o("light Re*eration")9ialog("light* ?able")9@inAutton("BC")9li @in+o("light Re*eration")9@inE+it("%ae;")9et ata?able9'#lue(4,1) @in+o("light Re*eration")9@inAutton("In*ert Br+er")9li
W#it &
Br+er%o = @in+o("light Re*eration")9@inE+it("Br+er %o;")9etRo$ropert( "text") ata?able9'#lue(5,1) = Br+er%o
Next
ata?able9Export("E;<In*ertBr+erRe*ult9xl*")