Vous êtes sur la page 1sur 44

VBScript General Examples

www.gcreddy.com

1) Write a program for finding out whether the given year is a leap year or not Dim xyear xyear=inputbox ("Enter Year") If xyear mod 4=0 Then msgbox "This is a Leap year" E se msgbox "This is !"T" End If !) Write a program for finding out whether the given num"er is# Even num"er or $dd num"er Dim num num=inputbox ("Enter a number") If num mod #=0 Then msgbox "This is a E$en !umber" E se msgbox "This is a "dd !umber" End If %) &ead two num"ers and display the sum Dim num%&num#& sum num%=inputbox ("Enter num%") num#=inputbox ("Enter num#") re,uire sum= 'db (num%) ( 'db (num#) )if *e *ant add t*o strings +on$ersion msgbox ("-um is " .sum) ') &ead (#)#& values and *alculate the Simple +nterest Dim p&t& r& si p=inputbox ("Enter /rin+ip e") t=inputbox ("Enter Time") r=inputbox ("Enter 0ate of Interest") si= (p1t1r)2%00 ) p= prin+ip e amount& t=time in years& r= rate of interest msgbox ("-imp e Interest is " .si) ,) &ead -our digit num"er# calculate . display the sum of the num"er or display Error message if the num"er is not a four digit num"er Dim num& sum num=inputbox ("Enter a 3our digit number") If Len(num) = 4 Then sum=0 sum=sum(num mod %0 num=num2%0 num= eft (num& 4)

sum=sum(num mod %0 num=num2%0 num= eft (num& #) sum=sum(num mod %0 num=num2%0 num= eft (num& %) sum=sum(num mod %0 msgbox ("-um is " .sum) e se msgbox "!umber& you entered is not a 4 digit number" End If /) &ead any -our0digit num"er and display the num"er in reverse order Dim num&re$ num= inputbox("Enter a number") If en(num)=4 Then re$=re$1%0 ( num mod %0 num=num2%0 num= eft(num&4) re$=re$1%0 ( num mod %0 num=num2%0 num= eft(num&#) re$=re$1%0 ( num mod %0 num=num2%0 num= eft(num&%) re$=re$1%0 ( num mod %0 E se End If msgbox "0e$erse "rder of the number is ".re$ msgbox "!umber& you entered is not a 4 digit number"

1) &ead ' su"2ects mar3s4 calculate the )otal mar3s and grade (a) If a$erage mar5s 6reater than or e,ua to 78& grade is Distin+tion b) If a$erage mar5s 6reater than or e,ua to 90 and ess than 78 & then grade is 3irst +) If a$erage mar5s 6reater than or e,ua to 80 and ess than 90 & then grade is -e+ond d) If a$erage mar5s 6reater than or e,ua to 40 and ess than 80 & then grade is Third e) :inimum mar5s 48 for any sub;e+t& other*ise )no grade fai )) Dim e&m&p&+& tot e=inputbox ("Enter eng ish :ar5s") m=inputbox ("Enter maths :ar5s") p=inputbox ("Enter physi+s :ar5s") +=inputbox ("Enter +hemistry :ar5s")

tot= +db (e) ( +db (m) ( +db (p) ( +db (+) msgbox tot If +db (e) <=48 and +db (m) <=48 and +db (p) <=48 and +db (+) <=48 and tot <=400 Then msgbox "6rade is Distin+tion" e se If +db (e) <=48 and +db (m) <=48 and +db (p) <=48 and +db (+) <=48 and tot <=#40 and tot=400 Then msgbox "6rade is 3irst" e se If +db (e) <=48 and +db (m) <=48 and +db (p) <=48 and +db (+) <=48 and tot <=#00 and tot=#40 Then msgbox "6rade is -e+ond" e se If +db (e) <=48 and +db (m) <=48 and +db (p) <=48 and +db (+) <=48 and tot <=%90 and tot=#00 Then msgbox "6rade is Third" e se msgbox "!o 6rade& 3ai " End End End End If If If If

5) 6isplay $dd num"ers up to n Dim num&n n=Inputbox ("Enter a >au e") 3or num= % to n step # msgbox num !ext 7) 6isplay Even num"ers up to n Dim num&n n=Inputbox ("Enter a >au e") 3or num= # to n step # msgbox num !ext 18) display natural num"ers up to n and write in a text file Dim num& n& fso& myfi e n= inputbox ("Enter any >a ue") num=% 3or num= % to n step % -et fso= +reateob;e+t ("s+ripting?fi esystemob;e+t") set myfi e=fso?opentextfi e ("E@Ag+r?txt"& B& true) myfi e?*rite ine num myfi e?+ ose

!ext 11) 6isplay 9atural num"ers in reverse order up to n Dim num&n n=Inputbox ("Enter a >au e") 3or num=n to % step C% msgbox num !ext 1!) 6isplay 9atural num"ers sum up to n Dim num& n& sum n= inputbox ("Enter a >a ue") sum=0 3or num= % to n step % sum= sum(num !ext msgbox sum 1%) 6isplay 9atural num"ers sum up to n :using While...Wend <oop) Dim num& n& sum n= inputbox ("Enter a >a ue") Dhi e num ==+db (n) sum= sum(num num=num(% Dend msgbox sum 1') 6isplay 9atural num"ers sum up to n :;sing 6o...;ntil...<oop) Dim num& n& sum n= inputbox ("Enter a >a ue") sum=0 num=% Do sum= sum(num num=num(% Loop Enti 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= sum(num !ext msgbox sum End 3un+tion :;sing -or...9ext <oop)

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=0ight (num&%) d#=mid (num& #& en d4=mid (num& 4& 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+ (d4) = "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+ >a ue" e se :sgbox "It is !"T !umeri+" End If

11) 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=0ight (num&%) d#=mid (num& #& en d4=mid (num& 4& 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+ (d4) = "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+ >a ue"

End If End If If en (num) =< %0 Then :sgbox "It is !"T $a id !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 1888 "ption exp i+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 e se 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 AaB is there or not in that data Dim x x=Inputbox ("Enter 4 digit $a ue")

x1=Right(x,1)
x#=Left (x&%) x4=mid (x&#&Len(%)) x4=mid (x&4&Len(%)) y= en(x) If y=4 Then If x%="a" or x#="a" or x4="a" or x4="a" Then msgbox "a is there" e se msgbox "a is !ot there" End If e se msgbox "In$a id Data"

End If !8) -or Each...9ext Statement 0epeats a group of statements for ea+h e ement in an array or +o e+tion Dim a&b&x (4) a=#0 b=40 x(0)= "Hddition is ". a(b x(%)="-ubstra+tion is " . aCb x(#)= ":u tip i+ation is " . a1b x(4)= "Di$ision is " . a2b 3or Ea+h e ement In x msgbox e ement !ext !1. Given num"er is primw or not

Option explicit Dim n, i, ounter ounter = ! n= cint(inputbox("enter nu"ber")) For i = 1 To n If n mod i = ! Then ounter = ounter # 1 End If Next If ounter = 2 Then msgbox "$ri"enu"ber" Else msgbox "%ot$ri"enu"ber" End If

&

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=)ca"e(inputbox("*nter the (trin%+")) ,ev(tr="trrever"e($'(tr)

if "trcomp($'(tr,,ev(tr)=0 then m"%box "-t i" a .alindrome"

'

el"e m"%box "-t i" not a .alindrome" end if

(rite a )b * ript to +i*pla, -a torial o- a nu"ber u*ing -un tion Answer sub fact(pnum) . 1 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=! -2=1 1!

-3=-1#-2 )ar= -1/","/-2 Do While -30n )ar = )ar/","/-3 -1=-2 -2=-3 -3=-1#-2 loop MsgBox )ar

.lea"e find m' code /ith 10 u"er and "avin% the 0rder number in m' created xl" 'Create excel obj Set m'xl=createobject("excel1application") m'xl12or3boo3"10pen"#+4)"er"4*a"el24De"3top45li%ht)-D" m'xl16pplication17i"ible=True Set m'"heet=m'xl16ctive2or3boo312or3"heet"("8o%in") For i = 1 To 10 .artner-D = m'"heet1cell"(i,"6")17alue .a""/ord = m'"heet1cell"(i,"9")17alue 'Invoke Flight Application "'"temutil1,un "#+4.ro%ram 5ile"4:.4)nified 5unctional Te"tin%4"ample"4fli%ht4app4fli%ht;a1exe" 'Enter Agent Name and Password Dialo%("8o%in")12in*dit("6 ")1Set .artner-D Dialo%("8o%in")12in*dit(".2")1Set .a""/ord Dialo%("8o%in")12in9utton("0<")1#lic3 'Enter Fly reservation rom to get !rderNo 2indo/("5li%ht ,e"ervation")12in0bject("Date of 5li%ht+")1T'pe "10121=" 2indo/("5li%ht ,e"ervation")12in#ombo9ox("5l' 5rom+")1Select 2 2indo/("5li%ht ,e"ervation")12in#ombo9ox("5l' To+")1Select > 2indo/("5li%ht ,e"ervation")12in9utton("58-?:T")1#lic3 2indo/("5li%ht ,e"ervation")1Dialo%("5li%ht" Table")12in8i"t("5rom")1Select = 2indo/("5li%ht ,e"ervation")1Dialo%("5li%ht" Table")12in9utton("0<")1#lic3 2indo/("5li%ht ,e"ervation")12in*dit(" ame+")1Set "6ja'" 11

2indo/("5li%ht ,e"ervation")12in,adio9utton("5ir"t")1#lic3 2indo/("5li%ht ,e"ervation")12in*dit("Tic3et"+")1Set = 2indo/("5li%ht ,e"ervation")12in9utton("-n"ert 0rder")1#lic3 wait 10 0rder o = 2indo/("5li%ht ,e"ervation")12in*dit("0rder o+")1?et,0.ropert'("text") Msgbox 0rder o m'"heet1cell"(i,"#")17alue = 0rder o 'Close Application 2indo/("5li%ht ,e"ervation")1#lo"e Next m'xl16ctive2or3boo31(ave m'xl16ctive2or3boo31#lo"e m'xl16pplication1@uit Set m'"heet = nothing Set m'xl = nothing
6im a 6im c:188) a @ C13!e%e'r,t/h1i5C " @ <en:a) -or i @ 1 to " c:i) @ Did:a#i#1) +f isnumeric:c:i)) )hen Dsg"ox c:i) End +f 9ext systemuti ?0un "iexp ore?exe"& "http@22ms +ampaignfa+tory?+om" -et a;ay in5s=des+ription?'reate a;ay in5s("mi++ ass")?>a ue = "Lin5" -et :-L = Iro*ser("+reationtime@=0")?/age("tit e@=?1")?'hi d"b;e+ts(a;ay in5s) Tota =:-L?+ount msgbox Tota 3or i = % To tota step C% my in5s= :-L(i)?6et0"/roperty("innertext") /rint my in5s

12

!ext

1) Verify <ogin Boundary ('he+5 a the boundary +onditions of the Login dia og box? 'he+5s to see if the +orre+t message appears in the error *indo* (3 ight 0eser$ation :essage) %) Hpp i+ationDir = En$ironment("/rodu+tDir") #) Hpp i+ation/ath = "Asamp esAf ightAappAf ight4a?exe" 4) If Dindo*("3 ight 0eser$ation")?Exist(#) Then 4) Dindo*("3 ight 0eser$ation")?' ose 8) -ystemEti ?0un Hpp i+ationDir . Hpp i+ation/ath 9) E seif !ot Dia og("Login")?Exist(%) Then 7) -ystemEti ?0un Hpp i+ationDir . Hpp i+ation/ath B) End If G) Dia og("Login")?DinEdit("Hgent !ame@")?-et Datatab e?>a ue ("Hgent!ame"&dt6 oba -heet) %0) Dia og("Login")?DinEdit("/ass*ord@")?-et Datatab e?>a ue ("/ass*ord"&dt6 oba -heet) %%) Dia og("Login")?DinIutton(""J")?' i+5 %#) If Dia og("Login")?Dia og("3 ight 0eser$ations")?Exist(%) and Datatab e?>a ue ("-tatus"&dt6 oba -heet)="3ai " Then %4) Dia og("Login")?Dia og("3 ight 0eser$ations")?-tati+("Hgent name must be at")?'he+5 'he+5/oint("Hgent name must be at east 4 +hara+ters ong?") %4) Dia og("Login")?Dia og("3 ight 0eser$ations")?DinIutton(""J")?' i+5 %8) E seif Dindo*("3 ight 0eser$ation")?Exist(%0) and Datatab e?>a ue ("-tatus"&dt6 oba -heet)="/ass" Then %9) 0eporter?0eportE$ent /H--&"Login@ "&"-u++eeded" %7) E se %B) 0eporter?0eportE$ent 3ai &"Login@ "&"'ombination K" . Datatab e?6et'urrent0o* . " *as not a++ording to Ex+e fi e" %G) End If !) Verify *ancel $peration (in Login Dia og box& if user se e+ts +an+e button& before enter any data after enter data dia og box shou d be disappeared?) %) In$o5eapp i+ation "'@A/rogram 3i esA:er+ury Intera+ti$eALui+5Test /rofessiona Asamp esAf ightAappAf ight4a?exe" #) Dia og("Login")?H+ti$ate 4) Dia og("Login")?DinIutton("'an+e ")?' i+5 4) If Dia og("Login")?Exist (#) =True Then 8) 0eporter?0eportE$ent %&"sd"&"3ai " 9) E se

13

7) 0eporter?0eportE$ent 0&"sd"&"/ass" B) In$o5eapp i+ation "'@A/rogram 3i esA:er+ury Intera+ti$eALui+5Test /rofessiona Asamp esAf ightAappAf ight4a?exe" G) End If %0) Dia og("Login")?H+ti$ate %%) Dia og("Login")?DinEdit("Hgent !ame@")?-et "asdf" %#) Dia og("Login")?DinIutton("'an+e ")?' i+5 %4) If Dia og("Login")?Exist (#) =True Then %4) 0eporter?0eportE$ent %&"sd"&"3ai " %8) E se %9) 0eporter?0eportE$ent 0&"sd"&"/ass" %7) In$o5eapp i+ation "'@A/rogram 3i esA:er+ury Intera+ti$eALui+5Test /rofessiona Asamp esAf ightAappAf ight4a?exe" %B) End If %G) Dia og("Login")?H+ti$ate #0) Dia og("Login")?DinEdit("Hgent !ame@")?-et "asdf" #%) Dia og("Login")?DinEdit("/ass*ord@")?-et-e+ure "4aGG4af48d+bd809+B48%b#74d#da07b4Bff884%" ##) Dia og("Login")?DinIutton("'an+e ")?' i+5 #4) If Dia og("Login")?Exist (#)=True Then #4) 0eporter?0eportE$ent %&"sd"&"3ai " #8) E se #9) 0eporter?0eportE$ent 0&"sd"&"/ass" #7) In$o5eapp i+ation "'@A/rogram 3i esA:er+ury Intera+ti$eALui+5Test /rofessiona Asamp esAf ightAappAf ight4a?exe" #B) End If #G) Dia og("Login")?H+ti$ate 40) Dia og("Login")?DinEdit("Hgent !ame@")?-et "asdf" 4%) Dia og("Login")?DinEdit("/ass*ord@")?-et-e+ure "4aGG4af48d+bd809+B48%b#74d#da07b4Bff884%" 4#) Dia og("Login")?DinIutton(""J")?' i+5 %) Verify Eddition# Su"traction# Dultiplication and 6ivision $perations in *alculator Epplication. %) #) 4) 4) 8) 9) 7) B) Dim a0es&s0es&d0es&m0es >bDindo*(">bDindo*")?H+ti$ate >bDindo*(">bDindo*")?>bEdit(">bEdit")?-et "%0" >bDindo*(">bDindo*")?>bEdit(">bEditM#")?-et "#0" $%=>bDindo*(">bDindo*")?>bEdit(">bEdit")?6et0"/roperty ("text") $#=>bDindo*(">bDindo*")?>bEdit(">bEditM#")?6et0"/roperty ("text") >bDindo*(">bDindo*")?>bIutton("HDD")?' i+5 a0es=>bDindo*(">bDindo*")?>bEdit(">bEditM4")?6et>isib eText

14

G) >bDindo*(">bDindo*")?>bIutton("-EI")?' i+5 %0) s0es=>bDindo*(">bDindo*")?>bEdit(">bEditM4")?6et>isib eText %%) >bDindo*(">bDindo*")?>bIutton(":EL")?' i+5 %#) m0es=>bDindo*(">bDindo*")?>bEdit(">bEditM4")?6et>isib eText %4) >bDindo*(">bDindo*")?>bIutton("DI>")?' i+5 %4) d0es=>bDindo*(">bDindo*")?>bEdit(">bEditM4")?6et>isib eText %8) $%=+db ($%) %9) $#=+db ($#) %7) a0es=+db (a0es) %B) s0es=+db (s0es) %G) m0es=+db (m0es) #0) d0es=+db (d0es) #%) If a0es=$%($# Then ##) 0eporter?0eportE$ent 0&"0es"&"Hddition /assed" #4) e se #4) 0eporter?0eportE$ent %&"0es"&"Hddition 3ai ed" #8) End If #9) If s0es=$%C$# Then #7) 0eporter?0eportE$ent 0&"0es"&"-ubtra+tion /assed" #B) e se #G) 0eporter?0eportE$ent %&"0es"&"-ubtra+tion 3ai ed" 40) End If 4%) If m0es=$%1$# Then 4#) 0eporter?0eportE$ent 0&"0es"&":u tip e+ation /assed" 44) e se 44) 0eporter?0eportE$ent %&"0es"&":u tip e+ation 3ai ed" 48) End If 49) If d0es=$%2$# Then 47) 0eporter?0eportE$ent 0&"0es"&"Di$ision /assed" 4B) e se 4G) 0eporter?0eportE$ent %&"0es"&"Di$ision 3ai ed" 40) End If ') Verify state of ;pdate $rder Button# "efore open an $rder and after open an $rder (in 3 ight 0eser$ation before opening an order Epdate "rder button shou d be disab ed after opening an order enab ed?) %) "ption exp i+it #) Dim bo&ao 4) If !ot *indo*("3 ight 0eser$ation")?Exist (#) Then 4) -ystemEti ?0un "'@A/rogram 3i esA:er+ury Intera+ti$eALui+5Test /rofessiona Asamp esAf ightAappAf ight4a?exe" 8) Dia og("Login")?H+ti$ate

15

9) Dia og("Login")?DinEdit("Hgent !ame@")?-et "6+reddy" 7) Dia og("Login")?DinEdit("/ass*ord@")?-et-e+ure "4aaBb+eGGB4f%a%8ea%B7a#da8b%B+848abb0%+f" B) Dia og("Login")?DinIutton(""J")?' i+5 G) End If %0) Dindo*("3 ight 0eser$ation")?H+ti$ate %%) bo=Dindo*("3 ight 0eser$ation")?DinIutton("Epdate "rder")?6et0"/roperty ("Enab ed") %#) Dindo*("3 ight 0eser$ation")?DinIutton("Iutton")?' i+5 %4) Dindo*("3 ight 0eser$ation")?Dia og(""pen "rder")?Din'he+5Iox(""rder !o?")?-et ""!" %4) Dindo*("3 ight 0eser$ation")?Dia og(""pen "rder")?DinEdit("Edit")?-et "%" %8) Dindo*("3 ight 0eser$ation")?Dia og(""pen "rder")?DinIutton(""J")?' i+5 %9) ao=Dindo*("3 ight 0eser$ation")?DinIutton("Epdate "rder")?6et0"/roperty ("Enab ed") %7) If bo=3a se Then %B) 0eporter?0eportE$ent 0&"0es"&"Epdate "rder Iutton Disab ed" %G) e se #0) 0eporter?0eportE$ent %&"0es"&"Epdate "rder Iutton Enab ed" #%) End If ##) If ao=True Then #4) 0eporter?0eportE$ent 0&"0es"&"Epdate "rder Iutton Enab ed" #4) e se #8) 0eporter?0eportE$ent %&"0es"&"Epdate "rder Iutton Disab ed" #9) End If ,) (rice *onsistency# +n -light &eservation (In 3 ight 0eser$ation& 3irst + ass pri+e=41E+onomy + ass pri+e and Iusiness + ass pri+e=#1E+onomy + ass pri+e) %) "ption exp i+it #) Dim n&f&b&e 4) If !ot *indo*("3 ight 0eser$ation")?Exist (#) Then 4) -ystemEti ?0un "'@A/rogram 3i esA:er+ury Intera+ti$eALui+5Test /rofessiona Asamp esAf ightAappAf ight4a?exe" 8) Dia og("Login")?H+ti$ate 9) Dia og("Login")?DinEdit("Hgent !ame@")?-et "asdf" 7) Dia og("Login")?DinEdit("/ass*ord@")?-et-e+ure "4aaBb7b7+8B#49B0+f+b#4d407%4+Gbbf0dff%eb" B) Dia og("Login")?DinIutton(""J")?' i+5 G) End If %0) 3or n= % to %0 step % %%) Dindo*("3 ight 0eser$ation")?H+ti$ate %#) Dindo*("3 ight 0eser$ation")?DinIutton("Iutton")?' i+5

16

%4) Dindo*("3 ight 0eser$ation")?Dia og(""pen "rder")?Din'he+5Iox(""rder !o?")?-et ""!" %4) Dindo*("3 ight 0eser$ation")?Dia og(""pen "rder")?DinEdit("Edit")?-et n %8) Dindo*("3 ight 0eser$ation")?Dia og(""pen "rder")?DinIutton(""J")?' i+5 %9) Dindo*("3 ight 0eser$ation")?Din0adioIutton("3irst")?-et %7) f=Dindo*("3 ight 0eser$ation")?DinEdit("/ri+e@")?6et>isib eText %B) Dindo*("3 ight 0eser$ation")?Din0adioIutton("Iusiness")?-et %G) b=Dindo*("3 ight 0eser$ation")?DinEdit("/ri+e@")?6et>isib eText #0) Dindo*("3 ight 0eser$ation")?Din0adioIutton("E+onomy")?-et #%) e=Dindo*("3 ight 0eser$ation")?DinEdit("/ri+e@")?6et>isib eText ##) f=+db (mid(f&#& en (fC%))) #4) b=+db (mid(b&#& en (bC%))) #4) e=+db (mid(e&#& en (eC%))) #8) If f=41e and b=#1e Then #9) 0eporter?0eportE$ent 0&"0es"&"/ri+y 'onsistan+y is there" #7) e se #B) 0eporter?0eportE$ent %&"0es"&"/ri+y 'onsistan+y is !"T there" #G) End If 40) Dindo*("3 ight 0eser$ation")?DinIutton("IuttonM#")?' i+5 4%) Dindo*("3 ight 0eser$ation")?Dia og("3 ight 0eser$ations")?DinIutton("!o")?' i+5 4#) !ext /) Verify )otal# +n -light &eservation (In 3 ight 0eser$ation& Tota = Ti+5ets 1 /ri+e) %) "ption Exp i+it #) Dim t&p&tot&n 4) 3or n= % to %0 step % 4) If !ot *indo*("3 ight 0eser$ation")?Exist (#) Then 8) -ystemEti ?0un "'@A/rogram 3i esA:er+ury Intera+ti$eALui+5Test /rofessiona Asamp esAf ightAappAf ight4a?exe"&""&"'@A/rogram 3i esA:er+ury Intera+ti$eALui+5Test /rofessiona Asamp esAf ightAappA"&"open" 9) Dia og("Login")?H+ti$ate 7) Dia og("Login")?DinEdit("Hgent !ame@")?-et "6+reddy" B) Dia og("Login")?DinEdit("/ass*ord@")?-et-e+ure "4aaBG#d9#+8#Gf%+#4#GB%78ad7B+8Bf44daBe44" G) Dia og("Login")?DinIutton(""J")?' i+5 %0) End If %%) Dindo*("3 ight 0eser$ation")?H+ti$ate %#) Dindo*("3 ight 0eser$ation")?DinIutton("Iutton")?' i+5 %4) Dindo*("3 ight 0eser$ation")?Dia og(""pen "rder")?Din'he+5Iox(""rder !o?")?-et ""!"

17

%4) %8) %9) %7) %B) %G) #0) #%) ##) #4) #4) #8) #9) #7)

Dindo*("3 ight 0eser$ation")?Dia og(""pen "rder")?DinEdit("Edit")?-et n Dindo*("3 ight 0eser$ation")?Dia og(""pen "rder")?DinIutton(""J")?' i+5 t=Dindo*("3 ight 0eser$ation")?DinEdit("Ti+5ets@")?6et>isib eText p=Dindo*("3 ight 0eser$ation")?DinEdit("/ri+e@")?6et>isib eText tot=Dindo*("3 ight 0eser$ation")?DinEdit("Tota @")?6et>isib eText t=+db (t) p='db (mid(p&#& en (pC%))) tot='db (mid(tot&#& en (totC%))) If tot=t1p Then 0eporter?0eportE$ent 0&"0es"&"'a +u ation /assed" e se 0eporter?0eportE$ent %&"0es"&"'a +u ation 3ai ed" End If !ext

1) Verify -light -rom . -light )o *om"o Boxes (In 3 ight reser$ation& se e+t an item from 3 y 3rom@ +ombo box and $erify *eather that item a$ai ab e or not in 3 y To@ +ombo box& i5e this se e+t a items one by one in 3 y 3rom and $erify *eather se e+ted items a$ai ab e or not in 3 y To?) %) "ption exp i+it #) Dim ,tp&f ightMapp&f&t&i&;&x&y 4) If !ot Dindo*("text@=3 ight 0eser$ation")?Exist (7)= True Then 4) LT/=En$ironment("/rodu+tDir") 8) 3 ightMapp="Asamp esAf ightAappAf ight4a?exe" 9) -ystemEti ?0un LT/ . 3 ightMapp 7) Dia og("text@=Login")?H+ti$ate B) Dia og("text@=Login")?DinEdit("atta+hed text@=Hgent !ame@")?-et "asdf" G) Dia og("text@=Login")?DinEdit("atta+hed text@=/ass*ord@")?-et-e+ure "4aa8ed4daf9B0e7a78Gbee%+84%G4Gd4a84a8b98" %0) Dia og("text@=Login")?DinIutton("text@="J")?' i+5 %%) End If %#) Dindo*("text@=3 ight 0eser$ation")?H+ti$ate %4) Dindo*("text@=3 ight 0eser$ation")?DinIutton("*indo* id@=9")?' i+5 %4) Dindo*("text@=3 ight 0eser$ation")?H+ti$eN("a+xMname@=:as5EdIox"&"*indo* id@=0")?Type "0G0G%0" %8) f=Dindo*("text@=3 ight 0eser$ation")?Din'omboIox("atta+hed text@=3 y 3rom@")?6etItems'ount %9) 3or i= 0 to fC% step % %7) Dindo*("text@=3 ight 0eser$ation")?Din'omboIox("atta+hed text@=3 y 3rom@")?-e e+t (i) %B) x=Dindo*("text@=3 ight 0eser$ation")?Din'omboIox("atta+hed text@=3 y 3rom@")?6et0"/roperty ("text")

1&

%G) t=Dindo*("text@=3 ight 0eser$ation")?Din'omboIox("atta+hed text@=3 y To@"&"x@=#44"&"y@=%47")?6etItems'ount #0) 3or ;= 0 to tC% step % #%) Dindo*("text@=3 ight 0eser$ation")?Din'omboIox("atta+hed text@=3 y To@"&"x@=#44"&"y@=%47")?-e e+t (;) ##) y=Dindo*("text@=3 ight 0eser$ation")?Din'omboIox("atta+hed text@=3 y To@"&"x@=#44"&"y@=%47")?6et0"/roperty ("text") #4) If x =< y Then #4) 0eporter?0eportE$ent 0&"0es"&"Test /assed" #8) E se #9) 0eporter?0eportE$ent %&"0es"&"Test 3ai ed" #7) End If #B) !ext #G) !ext 5) Verify $rder 9o Entry in -light &eservation. (In "pen "rder dia og box& "rder !o ob;e+t a++epts numeri+ $a ues on y?) %) If !ot *indo*("3 ight 0eser$ation")?Exist (#) Then #) -ystemEti ?0un "'@A/rogram 3i esA:er+ury Intera+ti$eALui+5Test /rofessiona Asamp esAf ightAappAf ight4a?exe" 4) Dia og("Login")?H+ti$ate 4) Dia og("Login")?DinEdit("Hgent !ame@")?-et "asdf" 8) Dia og("Login")?DinEdit("/ass*ord@")?-et-e+ure "4aaG++ae4bb00G9#b47ff7fb0+e48#4+%dBB+b44" 9) Dia og("Login")?DinIutton(""J")?' i+5 7) End If B) Dindo*("3 ight 0eser$ation")?H+ti$ate G) Dindo*("3 ight 0eser$ation")?DinIutton("Iutton")?' i+5 %0) Dindo*("3 ight 0eser$ation")?Dia og(""pen "rder")?Din'he+5Iox(""rder !o?")?-et ""!" %%) Dindo*("3 ight 0eser$ation")?Dia og(""pen "rder")?DinEdit("Edit")?-et "a" %#) ord=Dindo*("3 ight 0eser$ation")?Dia og(""pen "rder")?DinEdit("Edit")?6et>isib eText %4) If ord= "a" Then %4) 0eporter?0eportE$ent %&"0es"&""rder !o "b;e+t is ta5ing in$a id data" %8) e se %9) Dindo*("3 ight 0eser$ation")?Dia og(""pen "rder")?DinEdit("Edit")?-et "%" %7) Dindo*("3 ight 0eser$ation")?Dia og(""pen "rder")?DinIutton(""J")?' i+5 %B) End If 7) Get )est 6ata from a -lat file and use in 6ata 6riven )esting :through Scripting)

1'

%) Dim fso&myfi e #) -et fso=+reateob;e+t("s+ripting?fi esystemob;e+t") 4) -et myfi e= fso?opentextfi e ("3@Ag+r?txt"&%) 4) myfi e?s5ip ine 8) Dhi e myfi e?atendof ine =< True 9) x=myfi e?read ine 7) s=sp it (x& "&") B) -ystemEti ?0un "'@A/rogram 3i esA:er+ury Intera+ti$eALui+5Test /rofessiona Asamp esAf ightAappAf ight4a?exe" G) Dia og("Login")?H+ti$ate %0) Dia og("Login")?DinEdit("Hgent !ame@")?-et s(0) %%) Dia og("Login")?DinEdit("/ass*ord@")?-et-e+ure s(%) %#) Dia og("Login")?DinIutton(""J")?' i+5 %4) Dindo*("3 ight 0eser$ation")?' ose %4) Dend 18) *ount# how many Buttons and Edit "oxes availa"le in -light &eservation main window. %) If !ot *indo*("3 ight 0eser$ation")?Exist (#) Then #) -ystemEti ?0un "'@A/rogram 3i esA:er+ury Intera+ti$eALui+5Test /rofessiona Asamp esAf ightAappAf ight4a?exe" 4) Dia og("Login")?H+ti$ate 4) Dia og("Login")?DinEdit("Hgent !ame@")?-et "6+reddy" 8) Dia og("Login")?DinEdit("/ass*ord@")?-et "mer+ury" 9) Dia og("Login")?DinIutton(""J")?' i+5 7) End If B) -et oDes+ = Des+ription?'reate() G) oDes+("mi++ ass")?>a ue = "DinIutton" %0) -et Iuttons = Dindo*("text@=3 ight 0eser$ation")?'hi d"b;e+ts (oDes+) %%) !umMIuttons = Iuttons?'ount() %#) -et oDes+%=Des+ription?'reate() %4) oDes+%("mi++ ass")?>a ue="DinEdit" %4) -et Editboxes=Dindo*("text@=3 ight 0eser$ation")?'hi d"b;e+ts (oDes+%) %8) !umMEditboxes= editboxes?+ount () %9) sum= !umMIuttons(!umMEditboxes %7) 0eporter?0eportE$ent #& "0es"&"Tota Iuttons@ ". !umMIuttons ."Tota Edit boxes@ ". !umMEditboxes 11) Verify search options in $pen $rder 6ialog "ox (Hfter se e+ting open order& 4 sear+h options shou d be enab ed and not +he+5ed&

2!

Hfter se e+ting "rder !o option& other options shou d be disab ed& Hfter se e+ting 'ustomer !ame& 3 ight date option enab ed and "rder !o disab ed Hfter se e+ting 3 ight date option& 'ustomer !ame enab ed and "rder !o disab ed) %) If !ot *indo*("3 ight 0eser$ation")?Exist (#) Then #) -ystemEti ?0un "'@A/rogram 3i esA:er+ury Intera+ti$eALui+5Test /rofessiona Asamp esAf ightAappAf ight4a?exe" 4) Dia og("Login")?H+ti$ate 4) Dia og("Login")?DinEdit("Hgent !ame@")?-et "6+reddy" 8) Dia og("Login")?DinEdit("/ass*ord@")?-et-e+ure "4aaGed#8b+0ebde99ed7#9adB7d7eGG%447dBbG+" 9) Dia og("Login")?DinIutton(""J")?' i+5 7) End If B) Dindo*("3 ight 0eser$ation")?H+ti$ate G) Dindo*("3 ight 0eser$ation")?DinIutton("Iutton")?' i+5 %0) Dindo*("3 ight 0eser$ation")?Dia og(""pen "rder")?H+ti$ate %%) oe=Dindo*("3 ight 0eser$ation")?Dia og(""pen "rder")?Din'he+5Iox(""rder !o?")?6et0"/roperty ("Enab ed") %#) +e=Dindo*("3 ight 0eser$ation")?Dia og(""pen "rder")?Din'he+5Iox("'ustomer !ame")?6et0"/roperty ("Enab ed") %4) fe=Dindo*("3 ight 0eser$ation")?Dia og(""pen "rder")?Din'he+5Iox("3 ight Date")?6et0"/roperty("Enab ed") %4) o+=Dindo*("3 ight 0eser$ation")?Dia og(""pen "rder")?Din'he+5Iox(""rder !o?")?6et0"/roperty ("'he+5ed") %8) ++=Dindo*("3 ight 0eser$ation")?Dia og(""pen "rder")?Din'he+5Iox("'ustomer !ame")?6et0"/roperty ("'he+5ed") %9) f+=Dindo*("3 ight 0eser$ation")?Dia og(""pen "rder")?Din'he+5Iox("3 ight Date")?6et0"/roperty("'he+5ed") %7) If (oe=true and +e=true and fe=true) and (o+=""33" and ++=""33" and f+=""33") Then %B) 0eporter?0eportE$ent 0&"0es"&"/ass" %G) e se #0) 0eporter?0eportE$ent %&"0es"&"3ai " #%) End If ##) Dindo*("3 ight 0eser$ation")?Dia og(""pen "rder")?Din'he+5Iox(""rder !o?")?-et ""!" #4) ono=Dindo*("3 ight 0eser$ation")?Dia og(""pen "rder")?Din'he+5Iox(""rder !o?")?6et0"/roperty ("'he+5ed") #4) If ono=""!" Then #8) fd=Dindo*("3 ight 0eser$ation")?Dia og(""pen "rder")?Din'he+5Iox("3 ight Date")?6et0"/roperty ("Enab ed") #9) ono=Dindo*("3 ight 0eser$ation")?Dia og(""pen "rder")?Din'he+5Iox("'ustomer !ame")?6et0"/roperty ("Enab ed")

21

#7) fd=fa se #B) ono=fa se #G) 0eporter?0eportE$ent 0&"0es"&"/ass" 40) e se 4%) 0eporter?0eportE$ent %&"0es"&"3ai " 4#) End If 44) Dindo*("3 ight 0eser$ation")?Dia og(""pen "rder")?Din'he+5Iox(""rder !o?")?-et ""33" 44) Dindo*("3 ight 0eser$ation")?Dia og(""pen "rder")?Din'he+5Iox("'ustomer !ame")?-et ""!" 48) +n=Dindo*("3 ight 0eser$ation")?Dia og(""pen "rder")?Din'he+5Iox("'ustomer !ame")?6et0"/roperty ("'he+5ed") 49) If +n=""!" Then 47) ono=Dindo*("3 ight 0eser$ation")?Dia og(""pen "rder")?Din'he+5Iox(""rder !o?")?6et0"/roperty ("Enab ed") 4B) fd=Dindo*("3 ight 0eser$ation")?Dia og(""pen "rder")?Din'he+5Iox("3 ight Date")?6et0"/roperty ("Enab ed") 4G) fd=True 40) ono=fa se 4%) 0eporter?0eportE$ent 0&"0es"&"/ass" 4#) e se 44) 0eporter?0eportE$ent %&"0es"&"3ai " 44) End If 48) Dindo*("3 ight 0eser$ation")?Dia og(""pen "rder")?Din'he+5Iox("'ustomer !ame")?-et ""33" 49) Dindo*("3 ight 0eser$ation")?Dia og(""pen "rder")?Din'he+5Iox("3 ight Date")?-et ""!" 47) fd=Dindo*("3 ight 0eser$ation")?Dia og(""pen "rder")?Din'he+5Iox("3 ight Date")?6et0"/roperty ("'he+5ed") 4B) If fd=""!" Then 4G) ono=Dindo*("3 ight 0eser$ation")?Dia og(""pen "rder")?Din'he+5Iox(""rder !o?")?6et0"/roperty ("Enab ed") 80) +n=Dindo*("3 ight 0eser$ation")?Dia og(""pen "rder")?Din'he+5Iox("'ustomer !ame")?6et0"/roperty ("Enab ed") 8%) +n=True 8#) ono=fa se 84) 0eporter?0eportE$ent 0&"0es"&"/ass" 84) e se 88) 0eporter?0eportE$ent %&"0es"&"3ai " 89) End If 1!) +n <ogin 6ialog "ox# Verify Felp message (The message is OThe pass*ord is ):E0'E0Y))

22

%) If !ot Dia og("Login")?Exist (#) Then #) -ystemEti ?0un "'@A/rogram 3i esA:er+ury Intera+ti$eALui+5Test /rofessiona Asamp esAf ightAappAf ight4a?exe" 4) End If 4) Dia og("Login")?H+ti$ate 8) Dia og("Login")?DinIutton("Pe p")?' i+5 9) message=Dia og("Login")?Dia og("3 ight 0eser$ations")?-tati+("The pass*ord is ):E0'E0Y)")?6et0"/roperty("text") 7) If message="The pass*ord is ):E0'E0Y)" Then B) 0eporter?0eportE$ent 0&"0es"&"'orre+t message ".message G) e se %0) 0eporter?0eportE$ent %&"0es"&"Dorng message " %%) End If

File System Scripts


1) &ead *ontent from a text file and Write in another text file Dim ob;3so& my3i e%& my3i e#& x -et ob;3so=+reateob;e+t("-+ripting?3i esystemob;e+t") -et my3i e%=ob;3so?opentextfi e("'@ADo+uments and -ettingsAg+rADes5topAg+reddy?txt"&%) -et my3i e#=ob;3so?+reatetextfi e("'@ADo+uments and -ettingsAg+rADes5topAg+r,tp?txt"&%) Do Enti my3i e%?HtEnd"f-tream=True x=my3i e%?0ead ine my3i e#?Drite ine x Loop my3i e%?' ose my3i e#?' 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?3i esystemob;e+t") set ob;Text-tream=ob;3so?opentextfi e("'@ADo+uments and 23

-ettingsAg+rADes5topAg+reddy?txt"&%) -et ob;Text-tream#=ob;3so?opentextfi e("'@ADo+uments and -ettingsAg+rADes5topAg+r,tp?txt"&#) ob;Text-tream#?DriteLine "!umbers" ob;Text-tream#?DriteLine "CCCCCCCCC" Do Enti ob;Text-tream?HtEnd"f-tream myText=ob;Text-tream?0eadLine x=sp it(myText&" ") 3or i= bound(x) to ubound(x) If isnumeri+(x(i)) =True Then ob;Text-tream#?DriteLine x(i) End if !ext Loop ob;Text-tream?' ose ob;Text-tream#?' ose -et ob;3so=!othing %) G*ount <ines in a )ext -ile Dim ob;3so& ob;Textstream& Line'ount -et ob;3so='reate"b;e+t("-+ripting?fi esystemob;e+t") -et ob;Textstream=ob;3so?"penText3i e("'@ADo+uments and -ettingsAg+rADes5topAab+?txt") Do Dhi e !ot ob;Textstream?HtEnd"f-tream Line'ount = Line'ount ( % ob;Textstream?0eadLine Loop :sgbox Line'ount ob;Textstream?' ose -et ob;Textstream=!othing 24

-et ob;3so=!othing

! "reate a Folder 0ption *xplicit Dim obj5(0, obj5older, "trDirector' "trDirector' = "D+4?credd'" (et obj5(0 = #reate0bject("(criptin%15ile('"tem0bject") (et obj5older = obj5(01#reate5older("trDirector') #! $elete a Folder (et o5(0 = #reate0bject("(criptin%15ile('"tem0bject") o5(01Delete5older("*+4?credd'") %! "op&ing Folders (et o5(0=createobject("(criptin%15ile"'"temobject") o5(01#op'5older "*+4%cr", "#+4jvr", True '! "hecking weather the folder available or not( if not creating the folder 0ption *xplicit Dim obj5(0, obj5older, "trDirector' "trDirector' = "D+4?credd'" (et obj5(0 = #reate0bject("(criptin%15ile('"tem0bject") -f obj5(015older*xi"t"("trDirector') Then (et obj5older = obj5(01?et5older("trDirector') m"%box "trDirector' ! " alread' created " el"e (et obj5older = obj5(01#reate5older("trDirector') end if )! *eturning a collection of $isk $rives (et o5(0 = #reate0bject("(criptin%15ile('"tem0bject") (et colDrive" = o5(01Drive" 5or *ach oDrive in colDrive" $"%9ox "Drive letter+ " ! oDrive1Drive8etter ext

25

+! ,etting available space on a $isk $rive (et o5(0 = #reate0bject("(criptin%15ile('"tem0bject") (et oDrive = o5(01?etDrive("#+") $"%9ox "6vailable "pace+ " ! oDrive16vailable(pace

Flat File Scripts


*omputer -ile System It is a feature of the "perating -ystem& used to 'reate2:odify2$ie*2de ete Dri$es& 3o ders and 3i es $S 6istri"ution "perating -ystem and "ther Eti ities -ileSystem$"2ect >I-+ript has /ro$ided -ileSystem$"2ect to perform fi e system operations through s+ripting Dim ob;3so )'reating an Hutomation "b;e+t in 3i e -ystem + ass& that +an be used to perform "perations on 'omputer 3i e -ystem -et ob;3so='reate"b;e+t("s+ripting?3i e-ystem"b;e+t") 1) *reating a -ile Dim ob;3so -et ob;3so='reate"b;e+t("s+ripting?3i e-ystem"b;e+t") ob;3so?'reateText3i e ("E@A6+reddy?txt") ob;3so?'reateText3i e ("E@A6+reddy?do+") ob;3so?'reateText3i e ("E@A6+reddy?x s") ob;3so?'reateText3i e ("E@A6+reddy?pdf") 9oteH De +an 'reate other fi es a so& but they a+t as Text23 at 3i es -et ob;3i e = ob;3-"?'reateText3i e("E@A6+reddy?txt") !) *hec3ing weather the -ile is availa"le or not# if not creating the -ile strDire+tory="E@A" str3i e="6+reddy?txt"

26

-et ob;3-" = 'reate"b;e+t("-+ripting?3i e-ystem"b;e+t") If ob;3-"?3i eExists(strDire+tory . str3i e) Then -et ob;3o der = ob;3-"?6et3o der(strDire+tory) E se -et ob;3i e = ob;3-"?'reateText3i e("E@A6+reddy?txt") End if %) &eading 6ata character "y character from a -lat -ile -et ob;3-" = 'reate"b;e+t("-+ripting?3i e-ystem"b;e+t") -et ob;3i e = ob;3-"?"penText3i e("E@A6+reddy?txt"& %) Do Enti ob;3i e?HtEnd"f-tream str'hara+ters = ob;3i e?0ead(%) msgbox str'hara+ters Loop ') &eading 6ata line "y line from a -lat -ile -et ob;3-" = 'reate"b;e+t("-+ripting?3i e-ystem"b;e+t") -et ob;3i e = ob;3-"?"penText3i e("E@A6+reddy?txt"& %) Do Enti ob;3i e?HtEnd"f-tream str'hara+ters = ob;3i e?0ead ine msgbox str'hara+ters Loop ,) 6ata 6riven )esting "y fetching )est data directly from a )ext file. 11111111111111111111111111111111111111111111111111

G)est &eIuirementH Data Dri$en Testing by 3et+hing Test data dire+t y from a Text fi e? GEuthorH 6 ' 0eddy )Date of 'reation@ %4C0BC#0%0 G(re0reIuisitesH )g+r?txt (Test Data) G)est -lowH )'reating an Hutomation "b;e+t in 3i e-ystem + ass )"pening the Externa Test Data fi e using the "b;e+t )0ead the Data . -p it the Data 27

)6enerating the Login "peration )/ass /arameters )1111111111111111111111111111111111111111111111111 Dim ob;3so& my3i e& myLine& my3ie d -et ob;3so='reate"b;e+t("-+ripting?3i e-ystem"b;e+t") -et my3i e=ob;3so?"penText3i e("'@ADo+uments and -ettingsAg+r?6'0'CGH%#3ID4DGADes5topA$indod?txt"&%) )% for 0ead& #CDrite . BCHppend my3i e?-5ipLine Do Enti my3i e?HtEnd"f-tream myLine=my3i e?0eadLine my3ie d=-p it(myLine&"&") -ystemEti ?0un "'@A/rogram 3i esAP/ALui+5Test /rofessiona Asamp esAf ightAappAf ight4a?exe" Dia og("text@=Login")?H+ti$ate Dia og("text@=Login")?DinEdit("atta+hed text@=Hgent !ame@")?-et my3ie d(0) Dia og("text@=Login")?DinEdit("atta+hed text@=/ass*ord@")?-et my3ie d(%) *ait # Dia og("text@=Login")?DinIutton("text@="J")?' i+5 Dindo*("text@=3 ight 0eser$ation")?' ose Loop my3i e?' ose -et ob;3so=!othing
/) Writing data to a text file Dim -tuff& my3-"& Drite-tuff& date-tamp date-tamp = Date() -tuff = "I am /reparing this s+ript@ " .date-tamp -et my3-" = 'reate"b;e+t("-+ripting?3i e-ystem"b;e+t") -et Drite-tuff = my3-"?"penText3i e("e@A6+reddy?txt"& B& True) Drite-tuff?DriteLine(-tuff) Drite-tuff?' ose -ET Drite-tuff = !"TPI!6 -ET my3-" = !"TPI!6 1) 6elete a text file -et ob;3-"=+reateob;e+t("-+ripting?fi esystemob;e+t")

2&

-et txt3i epath = ob;3-"?6et3i e("E@Ag+r?txt") txt3i epath?De ete() 5) *hec3ing weather the -ile is availa"le or not# if availa"le delete the -ile strDire+tory="E@A" str3i e="g+r?txt" -et ob;3-" = 'reate"b;e+t("-+ripting?3i e-ystem"b;e+t") If ob;3-"?3i eExists(strDire+tory . str3i e) Then -et ob;3i e = ob;3-"?6etfi e(strDire+tory . str3i e) ob;3i e?de ete () End if 7) *omparing two text files Dim f%& f# f%="e@A6+reddy%?txt" f#="e@A6+reddy#?txt" /ub i+ 3un+tion 'ompare3i es (3i e/ath%& 3i e/ath#) Dim 3-& 3i e%& 3i e# -et 3- = 'reate"b;e+t("-+ripting?3i e-ystem"b;e+t") If 3-?6et3i e(3i e/ath%)?-iFe =< 3-?6et3i e(3i e/ath#)?-iFe Then 'ompare3i es = True Exit 3un+tion End If -et 3i e% = 3-?6et3i e(3i e/ath%)?"penHsText-tream(%& 0) -et 3i e# = 3-?6et3i e(3i e/ath#)?"penHsText-tream(%& 0) 'ompare3i es = 3a se Do Dhi e 3i e%?HtEnd"f-tream = 3a se -tr% = 3i e%?0ead -tr# = 3i e#?0ead 'ompare3i es = -tr'omp(-tr%& -tr#& 0) If 'ompare3i es =< 0 Then 'ompare3i es = True Exit Do End If Loop 3i e%?' ose() 3i e#?' ose() End 3un+tion 'a 'omparefi es(f%&f#) If 'ompare3i es(f%& f#) = 3a se Then :sgIox "3i es are identi+a ?"

2'

E se :sgIox "3i es are different?" End If 18) *ounting the num"er of times a word appears in a file s3i e!ame="E@Ag+r?txt" s-tring="g+reddy" 'onst 3"0M0EHDI!6 = % Dim o3so& oTxt3i e& s0eadTxt& o0egEx& o:at+hes -et o3so = 'reate"b;e+t("-+ripting?3i e-ystem"b;e+t") -et oTxt3i e = o3so?"penText3i e(s3i e!ame& 3"0M0EHDI!6) s0eadTxt = oTxt3i e?0eadH -et o0egEx = !e* 0egExp o0egEx?/attern = s-tring o0egEx?Ignore'ase = bIgnore'ase o0egEx?6 oba = True -et o:at+hes = o0egEx?Exe+ute(s0eadTxt) :at+hes3ound = o:at+hes?'ount -et oTxt3i e = !othing @ -et o3so = !othing @ -et o0egEx = !othing msgbox :at+hes3ound 11) &ead a *SV -ile ;sing 6ata"ase )echniIues "n Error 0esume !ext 'onst ad"pen-tati+ = 4 'onst adLo+5"ptimisti+ = 4 'onst ad'mdText = .P000% -et ob;'onne+tion = 'reate"b;e+t("HD"DI?'onne+tion") -et ob;0e+ord-et = 'reate"b;e+t("HD"DI?0e+ordset") str/athtoText3i e = "'@ADatabasesA" ob;'onne+tion?"pen "/ro$ider=:i+rosoft?Qet?"LEDI?4?0R" . M "Data -our+e=" . str/athtoText3i e . "R" . M "Extended /roperties=""textRPD0=YE-R3:T=De imited""" ob;0e+ordset?"pen "-ELE'T 1 30": /honeList?+s$"& M ob;'onne+tion& ad"pen-tati+& adLo+5"ptimisti+& ad'mdText Do Enti ob;0e+ordset?E"3

3!

Ds+ript?E+ho "!ame@ " . ob;0e+ordset?3ie ds?Item("!ame") Ds+ript?E+ho "Department@ " . M ob;0e+ordset?3ie ds?Item("Department") Ds+ript?E+ho "Extension@ " . ob;0e+ordset?3ie ds?Item("Extension") ob;0e+ordset?:o$e!ext Loop 1!) &ead a )ext -ile into an Erray 'onst 3or0eading = % -et ob;3-" = 'reate"b;e+t("-+ripting?3i e-ystem"b;e+t") -et ob;Text3i e = ob;3-"?"penText3i e M ("e@Ag+reddy?txt"& 3or0eading) Do Enti ob;Text3i e?HtEnd"f-tream str!extLine = ob;Text3i e?0ead ine arr-er$i+eList = -p it(str!extLine & "&") Ds+ript?E+ho "-er$er name@ " . arr-er$i+eList(0) 3or i = % to Ebound(arr-er$i+eList) Ds+ript?E+ho "-er$i+e@ " . arr-er$i+eList(i) !ext Loop 1%) G*alculate si=e of a )ext file Dim ob;3so& 3i e%&3i e# 3i e%="'@ADo+uments and -ettingsA% 0I6PHTDHYADes5topAxyF?txt" -et ob;3so='reate"b;e+t(" -+ripting?3i e-ystem"b;e+t") x= ob;3so?6et3i e(3i e%)?-iFe :sgbox x. " Iytes" 1') G)est &eIuirementH $pen 1 to 18 orders in -light &eservation # *apture *ustomer names and Export into a )ext file )Test 3 o*@ )Login "peration )"pen "rder "peration and form the Loop to open % to %0 "rders )'apture 'usomer names using 6et0"/roperty :ethod )'reate 3i e system "b;e+t and "pen the Text fi e using the "b;e+t and Export 'usomer names )CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC "ption Exp i+it Dim "rderM!umber& 'ustomerM!ame& ob;3so& my3i e -et ob;3so='reate"b;e+t("-+ripting?3i e-ystem"b;e+t") -et my3i e= ob;3so?'reateText3i e ("'@ADo+uments and -ettingsA% 0I6PHTDHYADes5topAab+!e*?txt"&#)

31

my3i e?DriteLine "'usomer !ames" my3i e?DriteLine "CCCCCCCCCCCCCCCCCCCC" If !ot Dindo*("3 ight 0eser$ation")?Exist(4) Then -ystemEti ?0un "'@A/rogram 3i esAP/ALui+5Test /rofessiona Asamp esAf ightAappAf ight4a?exe"&""&"'@A/rogram 3i esAP/ALui+5Test /rofessiona Asamp esAf ightAappA"&"open" Dia og("Login")?H+ti$ate Dia og("Login")?DinEdit("Hgent !ame@")?-et "asdf" Dia og("Login")?DinEdit("/ass*ord@")?-et-e+ure "4+4B8G0B70499bBd+080bbd#4eB%9BG0+747++fB" Dia og("Login")?DinIutton(""J")?' i+5 End If 3or "rderM!umber= % to %0 step % Dindo*("3 ight 0eser$ation")?H+ti$ate Dindo*("3 ight 0eser$ation")?DinIutton("Iutton")?' i+5 Dindo*("3 ight 0eser$ation")?Dia og(""pen "rder")?Din'he+5Iox(""rder !o?")?-et ""!" Dindo*("3 ight 0eser$ation")?Dia og(""pen "rder")?DinEdit("Edit")?-et "rderM!umber Dindo*("3 ight 0eser$ation")?Dia og(""pen "rder")?DinIutton(""J")?' i+5 'ustomerM!ame = Dindo*("3 ight 0eser$ation")?DinEdit("!ame@")?6et0"/roperty("text") *ait (#) my3i e?DriteLine 'ustomerM!ame !ext my3i e?' ose -et ob;3so=!othing %8) )111111111111111111111111111111111111111111111111111111 G)est &eIuirementH *apturing all Buttons 9ames from the <ogin 6ialog "ox and exporting to a )ext file )Huthor@ G * &eddy )Date of 'reation@ %4C0BC#0%0 G(re0reIuasitesH )g+r?txt G)est -lowH )'reating an Hutomation "b;e+t in 3i e-ystem + ass )"pening the Externa Test Data fi e using the "b;e+t )'reating 'o e+tion ob;e+t and 'apturing Iutton !ames using the "b;e+t )Driting Iutton !ames to an Externa Text fi e )11111111111111111111111111111111111111111111111111111111 Dim ob;3so& my3i e& oIutton& Iuttons& TotIuttons -et ob;3so='reate"b;e+t("-+ripting?3i e-ystem"b;e+t") -et my3i e=ob;3so?"penText3i e("'@ADo+uments and -ettingsAg+r?6'0'C GH%#3ID4DGADes5topA$indod?txt"&#) )% for 0ead& #CDrite . BCHppend my3i e?DriteLine "Iutton !ames" my3i e?DriteLine "CCCCCCCCCC"

32

-et oIutton=Des+ription?'reate oIutton("mi++ ass")?$a ue="DinIutton" -ystemEti ?0un "'@A/rogram 3i esAP/ALui+5Test /rofessiona Asamp esAf ightAappAf ight4a?exe" -et Iuttons=Dia og("text@=Login")?'hi d"b;e+ts(oIutton) TotIuttons=Iuttons?'ount 3or i= 0 to TotIuttonsC% myIutton=Iuttons(i)?6et0o/roperty("text") my3i e?DriteLine myIutton !ext my3i e?' ose -et ob;3so=!othing 1/) 6elete a )ext file if it is an empty file Dim ob;3so& 3i e/ath 3i e/ath="'@ADo+uments and -ettingsAg+reddyADes5topAab+?txt" -et ob;3so='reate"b;e+t("-+ripting?3i e-ystem"b;e+t") 3i e-iFe=ob;3so?6et3i e(3i e/ath)?-iFe ):sgbox 3i e-iFe If 3i e-iFe=0 Then ob;3so?De ete3i e(3i e/ath) End If -et ob;3so=!othing

6E)EBESE *$99E*)+$9
(et dbcon = createobject("6D0D91connection") dbcon10pen "D( =$a"terAmonitroA220=B)-D="aB.2D=Cualit'B6..=@uic3Te"t .rofe""ionalB2(-D=(D(BD6T696(*=ma"terB86 ?)6?*=u"Aen%li"h" m"%box dbcon1(tate &(et ocmd = createobject("6D0D91command") & ocmd16ctive#onnection = dbcon & ocmd1#ommandText = "(Cl Cuer'" & ocmd1*xecute (et r" = #reateobject("6D0D91,ecord"et") r"10pen ""elect E from dbo1"ptAmonitor",dbcon columencount = r"15ield"1#ount columnname" = r"15ield"(0)1 ame!vbtab!r"15ield"(1)1 ame Do /hile r"1*05 FG True r"1$ove5ir"t datavalue" = r"15ield"(0)17alue!vbtab!r"15ield"(1)17alue r"1$ove ext 33

8oop (et r" = nothin% (et dbcon = nothin%

12 ript to in)o3e the 4light Re*er)ation 5ppli ation 16he 3ing (hether a login * reen i* opene+ If Not 7ialog("8ogin")9Exi*t(!) Then 5pp:$ath = "6;<$rogra" 4ile*<=er ur, Intera ti)e<>ui 3?e*t $ro-e**ional<*a"ple*<-light<app<-light4a9exe" In!o"eApplic#tion 5pp:$ath En+ I12 ript to login in to the 5ppli ation 7ialog("8ogin")95 ti)ate 7ialog("8ogin")9@inE+it("5gent %a"e;")9$et "?e*tu*er" 7ialog("8ogin")9@inE+it("$a**(or+;")9$et ""er ur," 7ialog("8ogin")9@inAutton("BC")96li 3 12 ript to in*ert an or+er an+ print the Br+er %u"ber @in+o(("4light Re*er)ation")95 ti)ate @in+o(("4light Re*er)ation")9@inAutton("%e(")96li 3 @in+o(("4light Re*er)ation")9@inBbDe t("7ate o- 4light;")9T%pe "121212" @in+o(("4light Re*er)ation")9@in6o"boAox("4l, 4ro";")9$elect "4ran3-urt" @in+o(("4light Re*er)ation")9@in6o"boAox("4l, ?o;")9$elect "8o* 5ngele*" @in+o(("4light Re*er)ation")9@inAutton("48IEF?")96li 3 @in+o(("4light Re*er)ation")97ialog("4light* ?able")9@inAutton("BC")96li 3 @in+o(("4light Re*er)ation")9@inE+it("%a"e;")9$et "?e*t u*er" @in+o(("4light Re*er)ation")9@inAutton("In*ert Br+er")96li 3 W#it & Br+:%u" = @in+o(("4light Re*er)ation")9@inE+it("Br+er %o;")9EetRo$ropert,("text") =*gbox "?he Br+er %u"ber i*; "/Br+:%u" 12 ript to Bpen an Exi*ting Br+er 1Fere (e (ill a**u"e that the or+er i* alrea+, in*erte+ @in+o(("4light Re*er)ation")95 ti)ate @in+o(("4light Re*er)ation")9@inAutton("Bpen Autton")96li 3

34

@in+o(("4light Re*er)ation")97ialog( "Bpen Br+er")9@in6he 3Aox("6he 3 or+er")9$et "B%" @in+o(("4light Re*er)ation")97ialog("Bpen Br+er")9@inE+it("Br+er %u"ber")9$et Br+:%u" @in+o(("4light Re*er)ation")97ialog("Bpen Br+er")9@inAutton("BC")96li 3 12 ript to up+ate an exi*ting or+er @in+o(("4light Re*er)ation")95 ti)ate @in+o(("4light Re*er)ation")9@inBbDe t("7ate o- 4light;")9T%pe "111111" @in+o(("4light Re*er)ation")9@in6o"boAox("4l, 4ro";")9$elect "8o* 5ngele*" @in+o(("4light Re*er)ation")9@in6o"boAox("4l, ?o;")9$elect "4ran3-urt" @in+o(("4light Re*er)ation")9@inAutton("48IEF?")96li 3 @in+o(("4light Re*er)ation")97ialog("4light* ?able")9@inAutton("BC")96li 3 @in+o(("4light Re*er)ation")9@inE+it("%a"e;")9$et "?e*t G*er 1" @in+o(("4light Re*er)ation")9@inAutton("Gp+ate Br+er")96li 3 12 ript to lo*e the 5ppli ation @in+o(("4light Re*er)ation")9Close

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& &&&&&&&&&&&&&& 12 ript to in*ert an or+er -ro" external *prea+*heet 1$opulate the +ata into the global*heet, +e-ine the +atatable 1iteration* u*ing * ript an+ exe ute the in*ertor+er 12et the +atatable iteration* un+er te*t *etting* to 1Run one iteration onl, 12tep1; I"port the +ata into the Runti"e +atatable 7ata?able9I"port("E;<In*ert Br+er19xl*") 12tep 2; Eet the ro( ount an+ *tore it in a )ariable alle+ ro( ount ro( ount = 7ata?able9EetRo(6ount() 12tep 3; 2et the +atatable iteration*, iterate -ro" the -ir*t ro( till ro( ount

35

For i = 1 to ro( ount 12tep 4; 2et the urrent ro( a* the a ti)e ro( 7ata?able92et6urrentRo((i) 12tep 5; In*ert or+er * ript (ith appropriate para"eter* @in+o(("4light Re*er)ation")95 ti)ate @in+o(("4light Re*er)ation")9@inAutton("%e(")96li 3 @in+o(("4light Re*er)ation")9@inBbDe t("7ate o- 4light;")9T%pe 7ata?able9'#lue(1,1) @in+o(("4light Re*er)ation")9@in6o"boAox("4l, 4ro";")9$elect 7ata?able9'#lue(2,1) @in+o(("4light Re*er)ation")9@in6o"boAox("4l, ?o;")9$elect 7ata?able9'#lue(3,1) @in+o(("4light Re*er)ation")9@inAutton("48IEF?")96li 3 @in+o(("4light Re*er)ation")97ialog("4light* ?able")9@inAutton("BC")96li 3 @in+o(("4light Re*er)ation")9@inE+it("%a"e;")92et 7ata?able9'#lue(4,1) @in+o(("4light Re*er)ation")9@inAutton("In*ert Br+er")96li 3 W#it & Br+er%o = @in+o(("4light Re*er)ation")9@inE+it("Br+er %o;")9EetRo$ropert,("text") 7ata?able9'#lue(5,1) = Br+er%o Next 7ata?able9Export("E;<In*ertBr+erRe*ult9xl*")

@hen ,ou (or3 (ith ex el (or3*heet al(a,* 3eep in "in+ that the -ir*t ro( i* *et -or the para"eter na"e* i9e the -ir*t ro( olu"n* *houl+ ha)e the )ariable na"e* (hi h (e all in the * ript9

I- ,ou (ant the +ata to be i"porte+ to the global *heet then the +ata in the ex el -ile *houl+ be *tore+ in the 2heet 1 o- the -ile9 I- ,ou (ant the +ata to be i"porte+ to the 8o al *heet then the +ata in the ex el -ile *houl+ be *tore+ in 2heet 2 o- the -ile9 @e (ill para"etriHe the )ariable* (ith the ex el appli ation an+ +ire tl, pull in the +ata -ro" the olu"n* in the ex el *heet9

36

Write a script using Functions to invoke the Flight Reservation Application and pass the Login values from external Excel Sheet
8ogin4R u*erna"e, pa**(or+ $ubli 4un tion 8ogin4R(b,)al u*erna"e, b,)al pa**(or+) 16reate an BbDe t Variable to intera t (ith Ex el 8ibrar, 2et xlapp = 6reateBbDe t("Ex el95ppli ation") 1Bpen the exi*iting (or3boo3 2et (boo3 = xlapp9(or3boo3*9Bpen("E;<8ogin4lightR9xl*") 16reate a pointer to the -ir*t *heet in the (or3boo3 2et (*heet = xlapp9(or3*heet*(1) 1Eet the ro( ount ro( ount = (*heet9u*e+range9ro(*9 ount 4or i = 1 to ro( ountI1 I- not 7ialog("8ogin")9Exi*t(!) ?hen In)o3e5ppli ation "6;<$rogra" 4ile*<=er ur, Intera ti)e<>ui 3?e*t $ro-e**ional<*a"ple*<-light<app<-light4a9exe" En+ Iu*erna"e = (*heet9 ell*(i#1,1)9Value pa**(or+ = (*heet9 ell*(i#1,2)9Value 7ialog("8ogin")95 ti)ate 7ialog("8ogin")9@inE+it("5gent %a"e;")92et u*erna"e 7ialog("8ogin")9@inE+it("$a**(or+;")92et pa**(or+ 7ialog("8ogin")9@inAutton("BC")96li 3 @ait 1! I- @in+o(("4light Re*er)ation")9Exi*t(1!) ?hen (*heet9 ell*(i#1,3)9Value = "$a**"

37

(*heet9 ell*(i#1,3)94ont96olorin+ex = 1! El*e (*heet9 ell*(i#1,3)9Value = "4ail" (*heet9 ell*(i#1,3)9-ont9 olorin+ex = 3 En+ I@in+o(("4light Re*er)ation")96lo*e %ext (boo39*a)e (boo39 lo*e xlapp9Juit 2et (*heet = nothing 2et (boo3 = nothing 2et xlapp = nothing En+ 4un tion

Write a script to invole and login to the Flight Application using data from an external Excel Sheet
16reate an BbDe t Variable to intera t (ith Ex el 8ibrar, 2et xlapp = 6reateBbDe t("Ex el95ppli ation") 1Bpen the exi*ting (or3boo3 2et (boo3 = xlapp9@or3boo3*9Bpen("E;<$ra ti*e *et*<?e*t 7ata<8ogin4R9xl*") 16reate a pointer to the -ir*t *heet in the (or3boo3 2et (*heet = xlapp9@or32heet*(1) 1Eet the ro( ount ro( ount = (*heet9u*e+range9ro(*9 ount 4or i = 1 to ro( ountI1

3&

I- not 7ialog("8ogin")9Exi*t(!) ?hen In)o3e5ppli ation "6;<$rogra" 4ile*<=er ur, Intera ti)e<>ui 3?e*t $ro-e**ional<*a"ple*<-light<app<-light4a9exe" En+ I7ialog("8ogin")95 ti)ate 7ialog("8ogin")9@inE+it("5gent %a"e;")92et (*heet9 ell*(i#1,1)9Value 7ialog("8ogin")9@inE+it("$a**(or+;")92et (*heet9 ell*(i#1,2)9Value 7ialog("8ogin")9@inAutton("BC")96li 3 @ait & I- @in+o(("4light Re*er)ation")9Exi*t(&) ?hen (*heet9 ell*(i#1,3)9Value = "$a**" (*heet9 ell*(i#1,3)94ont96olorin+ex = 1! El*e (*heet9 ell*(i#1,3)9Value = "4ail" (*heet9 ell*(i#1,3)9-ont9 olorin+ex = 3 En+ I@in+o(("4light Re*er)ation")96lo*e %ext (boo39*a)e (boo39 lo*e xlapp9Juit 2et (*heet = nothing 2et (boo3 = nothing 2et xlapp = nothing

Write a script to insert an Order in flight Reservation Application importing values from an external excel sheet and also display the result as pass
12 ript to in*ert an or+er an+ print the Br+er %u"ber 16reate an obDe t to intera t (ith Ex el 8ibrar, 2et xlapp = 6reateBbDe t("Ex el95ppli ation") 1Bpen the ex el (or3boo3

3'

2et (boo3 = xlapp9(or3boo3*9Bpen("E;<In*ertBr+er9xl*") 12et the pointer to the (or3*heet 2et (*heet = xlapp9(or3*heet*(1) 1Eet ro( ount ro( ount = (*heet9u*e+range9ro(*9 ount 4or i = 1 to ro( ountI1 @in+o(("4light Re*er)ation")95 ti)ate @in+o(("4light Re*er)ation")9@inAutton("%e(")96li 3 @in+o(("4light Re*er)ation")9@inBbDe t("7ate o- 4light;")9?,pe (*heet9 ell*(i#1,1)9Value @in+o(("4light Re*er)ation")9@in6o"boAox("4l, 4ro";")92ele t (*heet9 ell*(i#1,2)9Value @in+o(("4light Re*er)ation")9@in6o"boAox("4l, ?o;")92ele t (*heet9 ell*(i#1,3)9Value @in+o(("4light Re*er)ation")9@inAutton("48IEF?")96li 3 @in+o(("4light Re*er)ation")97ialog("4light* ?able")9@inAutton("BC")96li 3 @in+o(("4light Re*er)ation")9@inE+it("%a"e;")92et (*heet9 ell*(i#1,4)9Value @in+o(("4light Re*er)ation")9@inAutton("In*ert Br+er")96li 3 @ait & Br+erno = @in+o(("4light Re*er)ation")9@inE+it("Br+er %o;")9EetRo$ropert,("text") (*heet9 ell*(i#1,5)9)alue = Br+erno I- @in+o(("4light Re*er)ation")9Exi*t(&) ?hen (*heet9 ell*(i#1,6)9Value = "$a**" (*heet9 ell*(i#1,6)94ont96olorin+ex = 1! El*e (*heet9 ell*(i#1,6)9Value = "4ail" (*heet9 ell*(i#1,6)9-ont9 olorin+ex = 3 En+ I%ext (boo39*a)e (boo39 lo*e xlapp9Juit 2et (*heet = nothing

4!

2et (boo3 = nothing 2et xlapp = nothing

Write a script in Q ! "#$ using Local data sheet

Write a script in Q ! "#$ using Local data sheet to invoke the application% login% &nsert order using Local data sheet and closing the application#
8oo3 at the -our a tion* in our te*t (e reate in >?$ 5 5 5 5 tion 1 K In)o3e 4light Re*er)ation 5ppli ation9 tion 2 K 8ogin to the 5ppli ation9 tion 3 K In*ert Br+er9 tion 4 K 6lo*e the 4light re*er)ation 5ppli ation9

Action ( ren#med #s In!o"e Applic#tion


If Not 7ialog("8ogin")9Exi*t(!) Then 5pp:$ath = "6;<$rogra" 4ile*<=er ur, Intera ti)e<>ui 3?e*t $ro-e**ional<*a"ple*<-light<app<-light4a9exe" In!o"eApplic#tion 5pp:$ath End If

Action ) ren#med #s *ogin


7ialog("8ogin")95 ti)ate 7ialog("8ogin")9@inE+it("5gent %a"e;")9$et "?e*tu*er" 7ialog("8ogin")9@inE+it("$a**(or+;")9$et ""er ur," 7ialog("8ogin")9@inAutton("BC")96li 3

Action + ren#med #s Insert Order Fere (e u*e the lo al +ata *heet (ith )alue* to be in*erte+9 @e (ill ha)e 7ateo-4light, 4l,4ro", 4l,?o, Br+er%o ((hi h (e (ill -et h to the +atatable -ro" appli ation u*ing EetRB$ropert,, Re*ult ba*e+ on the or+er%o generate+ (e (ill print pa** or -ail9

41

@in+o(("4light Re*er)ation")95 ti)ate @in+o(("4light Re*er)ation")9@inAutton("%e(")96li 3 @in+o(("4light Re*er)ation")9@inBbDe t("7ate o- 4light;")9T%pe 7ata?able("7ateo-4light", +t8o al2heet) @in+o(("4light Re*er)ation")9@in6o"boAox("4l, 4ro";")9$elect 7ata?able("4l,4ro"", +t8o al2heet) @in+o(("4light Re*er)ation")9@in6o"boAox("4l, ?o;")9$elect 7ata?able("4l,?o", +t8o al2heet) @in+o(("4light Re*er)ation")9@inAutton("48IEF?")96li 3 @in+o(("4light Re*er)ation")97ialog("4light* ?able")9@inAutton("BC")96li 3 @in+o(("4light Re*er)ation")9@inE+it("%a"e;")9$et 7ata?able("%a"e", +t8o al2heet) @in+o(("4light Re*er)ation")9@inAutton("In*ert Br+er")96li 3 W#it & Br+erno = @in+o(("4light Re*er)ation")9@inE+it("Br+er %o;")9EetRo$ropert,("text") 7ata?able("Br+erno",+t8o al2heet) = Br+erno If Br+erno = " " Then 7ata?able("Re*ult",+t8o al2heet) = "4ail" El*e 7ata?able("Re*ult",+t8o al2heet) = "$a**" End If

Action , ren#med #s Close


@in+o(("4light Re*er)ation")96lo*e

42

Write a script in Q ! to import data from an external data sheet using Excel application File system o'(ect)

We *ill *rite a script and import the run time data from the external excel sheet and also fetch the order num'er to the run time data ta'le and store it under the orderno column# Also *e *ould print a pass or a fail 'ased on the order no# &f the order num'er is generated then it *ill print pass and in green color and if the order num'er is not generated then it *ill print fail in green color under the result column# For this apart from the four columns you need to add a column for Orderno and a column for Results and leave them 'lank 'ecause the values *ill 'e inserted during run time#
12 ript to in*ert an or+er an+ print the Br+er %u"ber 16reate an obDe t to intera t (ith Ex el 8ibrar, $et xlapp = Cre#teOb-ect("Ex el95ppli ation") 1Bpen the ex el (or3boo3 $et (boo3 = xlapp9(or3boo3*9Bpen("E;<In*ertBr+er9xl*") 12et the pointer to the (or3*heet $et (*heet = xlapp9(or3*heet*(1) 1Eet ro( ount ro( ount = (*heet9u*e+range9ro(*9count For i = 1 to ro( ountI1 @in+o(("4light Re*er)ation")95 ti)ate @in+o(("4light Re*er)ation")9@inAutton("%e(")96li 3

43

@in+o(("4light Re*er)ation")9@inBbDe t("7ate o- 4light;")9T%pe (*heet9 ell*(i#1,1)9'#lue @in+o(("4light Re*er)ation")9@in6o"boAox("4l, 4ro";")9$elect (*heet9 ell*(i#1,2)9'#lue @in+o(("4light Re*er)ation")9@in6o"boAox("4l, ?o;")9$elect (*heet9 ell*(i#1,3)9'#lue @in+o(("4light Re*er)ation")9@inAutton("48IEF?")96li 3 @in+o(("4light Re*er)ation")97ialog("4light* ?able")9@inAutton("BC")96li 3 @in+o(("4light Re*er)ation")9@inE+it("%a"e;")9$et (*heet9 ell*(i#1,4)9'#lue @in+o(("4light Re*er)ation")9@inAutton("In*ert Br+er")96li 3 W#it & Br+erno = @in+o(("4light Re*er)ation")9@inE+it("Br+er %o;")9EetRo$ropert,("text") (*heet9 ell*(i#1,5)9'#lue = Br+erno If Br+erno = null Then (*heet9 ell*(i#1,6)9'#lue = "4ail" (*heet9 ell*(i#1,6)94ont96olorin+ex = 3 El*e (*heet9 ell*(i#1,6)9Value = "$a**" (*heet9 ell*(i#1,6)9-ont9 olorin+ex = 1! End If Next (boo39*a)e (boo39close xlapp9Juit $et (*heet = nothing $et (boo3 = nothing $et xlapp = nothing

.e#d more/ http/001tp,free2blogspot2in0)3(30340write5script5in51tp5to5import5d#t#5 from2html6ix77)8#9sFBgO

44