VB Programs

May 16, 2018 | Author: BalaSai Varma | Category: Data, Computer Data, Computer File, Technology, Computing
Share Embed Donate


Short Description

Download VB Programs...

Description

VBScript General Examples

www.gcreddy.com

1

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#") sum= 'db (num%)  'db (num#) if *e *ant add t*o strings +on$ersion re,uire msgbox ("-um is " .sum) ') &ead (##& values and *alculate *alculate the Simple +nterest Dim p&t& r& si p=inputbox ("Enter /rin+ipe") t=inputbox ("Enter Time") r=inputbox ("Enter ate 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# num"er# calculate  display 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 Then sum=0 sum=sumnum sum=sumnum mod %0 num=num2%0 num= eft (num& )

2

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#") sum= 'db (num%)  'db (num#) if *e *ant add t*o strings +on$ersion re,uire msgbox ("-um is " .sum) ') &ead (##& values and *alculate *alculate the Simple +nterest Dim p&t& r& si p=inputbox ("Enter /rin+ipe") t=inputbox ("Enter Time") r=inputbox ("Enter ate 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# num"er# calculate  display 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 Then sum=0 sum=sumnum sum=sumnum mod %0 num=num2%0 num= eft (num& )

2

sum=sumnum sum=sumnum mod %0 num=num2%0 num= eft (num& #) sum=sumnum sum=sumnum mod %0 num=num2%0 num= eft (num& %) sum=sum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&) 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 msgbox "e$erse rder of the number is ".re$ Ese msgbox "!umber& you entered is not a 4 digit number" End If  ) &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 8 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")

3

tot= +db(e)  +db(m)  +db(p)  +db(+) msgbox tot

If +db(e) bindo*(">bindo*")?>bEdit(">bEditM")?6et>isibeText

14

G) >bindo*(">bindo*")?>button("-")?'i+5 %0) ses=>bindo*(">bindo*")?>bEdit(">bEditM")?6et>isibeText %%) >bindo*(">bindo*")?>button(":L")?'i+5 %#) mes=>bindo*(">bindo*")?>bEdit(">bEditM")?6et>isibeText %) >bindo*(">bindo*")?>button("DI>")?'i+5 %4) des=>bindo*(">bindo*")?>bEdit(">bEditM")?6et>isibeText %8) $%=+db($%) %9) $#=+db($#) %7) aes=+db (aes) %B) ses=+db (ses) %G) mes=+db (mes) #0) des=+db (des) #%) If aes=$%$# Then ##) eporter?eportE$ent 0&"es"&"Hddition /assed" #) ese #4) eporter?eportE$ent %&"es"&"Hddition 3aied" #8) End If  #9) If ses=$%C$# Then #7) eporter?eportE$ent 0&"es"&"-ubtra+tion /assed" #B) ese #G) eporter?eportE$ent %&"es"&"-ubtra+tion 3aied" 0) End If  %) If mes=$%1$# Then #) eporter?eportE$ent 0&"es"&":utipe+ation /assed" ) ese 4) eporter?eportE$ent %&"es"&":utipe+ation 3aied" 8) End If  9) If des=$%2$# Then 7) eporter?eportE$ent 0&"es"&"Di$ision /assed" B) ese G) eporter?eportE$ent %&"es"&"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 eser$ation before opening an order pdate rder button shoud be disabed after opening an order enabed?) %) ption expi+it #) Dim bo&ao ) If !ot *indo*("3ight eser$ation")?Exist (#) Then 4) -ystemti?un "'@A/rogram 3iesA:er+ury Intera+ti$eAui+5Test /rofessionaAsampesAfightAappAfight4a?exe" 8) Diaog("Login")?H+ti$ate

15

9) Diaog("Login")?inEdit("Hgent !ame@")?-et "6+reddy" 7) Diaog("Login")?inEdit("/ass*ord@")?-et-e+ure "4aaBb+eGGB4f%a%8ea%B7a#da8b%B+848abb0%+f" B) Diaog("Login")?inutton("J")?'i+5 G) End If  %0) indo*("3ight eser$ation")?H+ti$ate %%) bo=indo*("3ight eser$ation")?inutton("pdate rder")?6et/roperty ("Enabed") %#) indo*("3ight eser$ation")?inutton("utton")?'i+5 %) indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("rder !o?")?-et "!" %4) indo*("3ight eser$ation")?Diaog("pen rder")?inEdit("Edit")?-et "%" %8) indo*("3ight eser$ation")?Diaog("pen rder")?inutton("J")?'i+5 %9) ao=indo*("3ight eser$ation")?inutton("pdate rder")?6et/roperty ("Enabed") %7) If bo=3ase Then %B) eporter?eportE$ent 0&"es"&"pdate rder utton Disabed" %G) ese #0) eporter?eportE$ent %&"es"&"pdate rder utton Enabed" #%) End If  ##) If ao=True Then #) eporter?eportE$ent 0&"es"&"pdate rder utton Enabed" #4) ese #8) eporter?eportE$ent %&"es"&"pdate rder utton Disabed" #9) End If  ,) (rice *onsistency# +n -light &eservation (In 3ight eser$ation& 3irst +ass pri+e=1E+onomy +ass pri+e and usiness +ass pri+e=#1E+onomy +ass pri+e) %) ption expi+it #) Dim n&f&b&e ) If !ot *indo*("3ight eser$ation")?Exist (#) Then 4) -ystemti?un "'@A/rogram 3iesA:er+ury Intera+ti$eAui+5Test /rofessionaAsampesAfightAappAfight4a?exe" 8) Diaog("Login")?H+ti$ate 9) Diaog("Login")?inEdit("Hgent !ame@")?-et "asdf" 7) Diaog("Login")?inEdit("/ass*ord@")?-et-e+ure "4aaBb7b7+8B#9B0+f+b#4d07%4+Gbbf0dff%eb" B) Diaog("Login")?inutton("J")?'i+5 G) End If  %0) 3or n= % to %0 step % %%) indo*("3ight eser$ation")?H+ti$ate %#) indo*("3ight eser$ation")?inutton("utton")?'i+5

16

%) indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("rder !o?")?-et "!" %4) indo*("3ight eser$ation")?Diaog("pen rder")?inEdit("Edit")?-et n %8) indo*("3ight eser$ation")?Diaog("pen rder")?inutton("J")?'i+5 %9) indo*("3ight eser$ation")?inadioutton("3irst")?-et %7) f=indo*("3ight eser$ation")?inEdit("/ri+e@")?6et>isibeText %B) indo*("3ight eser$ation")?inadioutton("usiness")?-et %G) b=indo*("3ight eser$ation")?inEdit("/ri+e@")?6et>isibeText #0) indo*("3ight eser$ation")?inadioutton("E+onomy")?-et #%) e=indo*("3ight eser$ation")?inEdit("/ri+e@")?6et>isibeText ##) 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) ese #B) eporter?eportE$ent %&"es"&"/ri+y 'onsistan+y is !T there" #G) End If  0) indo*("3ight eser$ation")?inutton("uttonM#")?'i+5 %) indo*("3ight eser$ation")?Diaog("3ight eser$ations")?inutton("!o")?'i+5 #) !ext /) Verify otal# +n -light &eservation (In 3ight eser$ation& Tota = Ti+5ets 1 /ri+e) %) ption Expi+it #) Dim t&p&tot&n ) 3or n= % to %0 step % 4) If !ot *indo*("3ight eser$ation")?Exist (#) Then 8) -ystemti?un "'@A/rogram 3iesA:er+ury Intera+ti$eAui+5Test /rofessionaAsampesAfightAappAfight4a?exe"&""&"'@A/rogram 3iesA:er+ury Intera+ti$eAui+5Test /rofessionaAsampesAfightAappA"&"open" 9) Diaog("Login")?H+ti$ate 7) Diaog("Login")?inEdit("Hgent !ame@")?-et "6+reddy" B) Diaog("Login")?inEdit("/ass*ord@")?-et-e+ure "4aaBG#d9#+8#Gf%+##GB%78ad7B+8Bf4daBe4" G) Diaog("Login")?inutton("J")?'i+5 %0) End If  %%) indo*("3ight eser$ation")?H+ti$ate %#) indo*("3ight eser$ation")?inutton("utton")?'i+5 %) indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("rder !o?")?-et "!"

17

%4) indo*("3ight eser$ation")?Diaog("pen rder")?inEdit("Edit")?-et n %8) indo*("3ight eser$ation")?Diaog("pen rder")?inutton("J")?'i+5 %9) t=indo*("3ight eser$ation")?inEdit("Ti+5ets@")?6et>isibeText %7) p=indo*("3ight eser$ation")?inEdit("/ri+e@")?6et>isibeText %B) tot=indo*("3ight eser$ation")?inEdit("Tota@")?6et>isibeText %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+uation /assed" #4) ese #8) eporter?eportE$ent %&"es"&"'a+uation 3aied" #9) End If  #7) !ext ) 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 ) If !ot indo*("text@=3ight eser$ation")?Exist (7)= True Then 4) T/=En$ironment("/rodu+tDir") 8) 3ightMapp="AsampesAfightAappAfight4a?exe" 9) -ystemti?un T/ . 3ightMapp 7) Diaog("text@=Login")?H+ti$ate B) Diaog("text@=Login")?inEdit("atta+hed text@=Hgent !ame@")?-et "asdf" G) Diaog("text@=Login")?inEdit("atta+hed text@=/ass*ord@")?-et-e+ure "4aa8eddaf9B0e7a78Gbee%+84%GGda84a8b98" %0) Diaog("text@=Login")?inutton("text@=J")?'i+5 %%) End If  %#) indo*("text@=3ight eser$ation")?H+ti$ate %) indo*("text@=3ight eser$ation")?inutton("*indo* id@=9")?'i+5 %4) indo*("text@=3ight eser$ation")?H+ti$eN("a+xMname@=:as5Edox"&"*indo* id@=0")?Type "0G0G%0" %8) f=indo*("text@=3ight eser$ation")?in'omboox("atta+hed text@=3y 3rom@")?6etItems'ount %9) 3or i= 0 to fC% step % %7) indo*("text@=3ight eser$ation")?in'omboox("atta+hed text@=3y 3rom@")?-ee+t (i) %B) x=indo*("text@=3ight eser$ation")?in'omboox("atta+hed text@=3y 3rom@")?6et/roperty ("text")

1&

%G) t=indo*("text@=3ight eser$ation")?in'omboox("atta+hed text@=3y To@"&"x@=#44"&"y@=%47")?6etItems'ount #0) 3or ;= 0 to tC% step % #%) indo*("text@=3ight eser$ation")?in'omboox("atta+hed text@=3y To@"&"x@=#44"&"y@=%47")?-ee+t (;) ##) y=indo*("text@=3ight eser$ation")?in'omboox("atta+hed text@=3y To@"&"x@=#44"&"y@=%47")?6et/roperty ("text") #) If x < y Then #4) eporter?eportE$ent 0&"es"&"Test /assed" #8) Ese #9) eporter?eportE$ent %&"es"&"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 eser$ation")?Exist (#) Then #) -ystemti?un "'@A/rogram 3iesA:er+ury Intera+ti$eAui+5Test /rofessionaAsampesAfightAappAfight4a?exe" ) Diaog("Login")?H+ti$ate 4) Diaog("Login")?inEdit("Hgent !ame@")?-et "asdf" 8) Diaog("Login")?inEdit("/ass*ord@")?-et-e+ure "4aaG++aebb00G9#b47ff7fb0+e8#4+%dBB+b4" 9) Diaog("Login")?inutton("J")?'i+5 7) End If  B) indo*("3ight eser$ation")?H+ti$ate G) indo*("3ight eser$ation")?inutton("utton")?'i+5 %0) indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("rder !o?")?-et "!" %%) indo*("3ight eser$ation")?Diaog("pen rder")?inEdit("Edit")?-et "a" %#) ord=indo*("3ight eser$ation")?Diaog("pen rder")?inEdit("Edit")?6et>isibeText %) If ord= "a" Then %4) eporter?eportE$ent %&"es"&"rder !o b;e+t is ta5ing in$aid data" %8) ese %9) indo*("3ight eser$ation")?Diaog("pen rder")?inEdit("Edit")?-et "%" %7) indo*("3ight eser$ation")?Diaog("pen rder")?inutton("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") ) -et myfie= fso?opentextfie ("3@Ag+r?txt"&%) 4) myfie?s5ipine 8) hie myfie?atendofine < True 9) x=myfie?readine 7) s=spit (x& "&") B) -ystemti?un "'@A/rogram 3iesA:er+ury Intera+ti$eAui+5Test /rofessionaAsampesAfightAappAfight4a?exe" G) Diaog("Login")?H+ti$ate %0) Diaog("Login")?inEdit("Hgent !ame@")?-et s(0) %%) Diaog("Login")?inEdit("/ass*ord@")?-et-e+ure s(%) %#) Diaog("Login")?inutton("J")?'i+5 %) indo*("3ight eser$ation")?'ose %4) end 18) *ount# how many Buttons and Edit "oxes availa"le in -light &eservation main window. %) If !ot *indo*("3ight eser$ation")?Exist (#) Then #) -ystemti?un "'@A/rogram 3iesA:er+ury Intera+ti$eAui+5Test /rofessionaAsampesAfightAappAfight4a?exe" ) Diaog("Login")?H+ti$ate 4) Diaog("Login")?inEdit("Hgent !ame@")?-et "6+reddy" 8) Diaog("Login")?inEdit("/ass*ord@")?-et "mer+ury" 9) Diaog("Login")?inutton("J")?'i+5 7) End If  B) -et oDes+ = Des+ription?'reate() G) oDes+("mi++ass")?>aue = "inutton" %0) -et uttons = indo*("text@=3ight eser$ation")?'hidb;e+ts (oDes+) %%) !umMuttons = uttons?'ount() %#) -et oDes+%=Des+ription?'reate() %) oDes+%("mi++ass")?>aue="inEdit" %4) -et Editboxes=indo*("text@=3ight eser$ation")?'hidb;e+ts (oDes+%) %8) !umMEditboxes= editboxes?+ount () %9) sum= !umMuttons!umMEditboxes %7) eporter?eportE$ent #& "es"&"Tota uttons@ ". !umMuttons ."Tota Edit boxes@ ". !umMEditboxes 11) Verify search options in $pen $rder 6ialog "ox (Hfter see+ting open order&  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 eser$ation")?Exist (#) Then #) -ystemti?un "'@A/rogram 3iesA:er+ury Intera+ti$eAui+5Test /rofessionaAsampesAfightAappAfight4a?exe" ) Diaog("Login")?H+ti$ate 4) Diaog("Login")?inEdit("Hgent !ame@")?-et "6+reddy" 8) Diaog("Login")?inEdit("/ass*ord@")?-et-e+ure "4aaGed#8b+0ebde99ed7#9adB7d7eGG%47dBbG+" 9) Diaog("Login")?inutton("J")?'i+5 7) End If  B) indo*("3ight eser$ation")?H+ti$ate G) indo*("3ight eser$ation")?inutton("utton")?'i+5 %0) indo*("3ight eser$ation")?Diaog("pen rder")?H+ti$ate %%) oe=indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("rder !o?")?6et/roperty ("Enabed") %#) +e=indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("'ustomer !ame")?6et/roperty ("Enabed") %) fe=indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("3ight Date")?6et/roperty("Enabed") %4) o+=indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("rder !o?")?6et/roperty ("'he+5ed") %8) ++=indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("'ustomer !ame")?6et/roperty ("'he+5ed") %9) f+=indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("3ight 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) ese #0) eporter?eportE$ent %&"es"&"3ai" #%) End If  ##) indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("rder !o?")?-et "!" #) ono=indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("rder !o?")?6et/roperty ("'he+5ed") #4) If ono="!" Then #8) fd=indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("3ight Date")?6et/roperty ("Enabed") #9) ono=indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("'ustomer !ame")?6et/roperty ("Enabed")

21

#7) fd=fase #B) ono=fase #G) eporter?eportE$ent 0&"es"&"/ass" 0) ese %) eporter?eportE$ent %&"es"&"3ai" #) End If  ) indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("rder !o?")?-et "33" 4) indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("'ustomer !ame")?-et "!" 8) +n=indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("'ustomer !ame")?6et/roperty ("'he+5ed") 9) If +n="!" Then 7) ono=indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("rder !o?")?6et/roperty ("Enabed") B) fd=indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("3ight Date")?6et/roperty ("Enabed") G) fd=True 40) ono=fase 4%) eporter?eportE$ent 0&"es"&"/ass" 4#) ese 4) eporter?eportE$ent %&"es"&"3ai" 44) End If  48) indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("'ustomer !ame")?-et "33" 49) indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("3ight Date")?-et "!" 47) fd=indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("3ight Date")?6et/roperty ("'he+5ed") 4B) If fd="!" Then 4G) ono=indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("rder !o?")?6et/roperty ("Enabed") 80) +n=indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("'ustomer !ame")?6et/roperty ("Enabed") 8%) +n=True 8#) ono=fase 8) eporter?eportE$ent 0&"es"&"/ass" 84) ese 88) eporter?eportE$ent %&"es"&"3ai" 89) End If  1!) +n -+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 e +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 nti ob;3ie?HtEndf-tream str'hara+ters = ob;3ie?ead(%) 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 nti ob;3ie?HtEndf-tream str'hara+ters = ob;3ie?eadine 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+ty from a Text fie? uthorH 6 ' eddy Date of 'reation@ %C0BC#0%0 (re0reIuisitesH g+r?txt (Test Data) 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 ead 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''CGH%#3DDGADes5topA$indod?txt"&%) % for ead& #Crite . BCHppend my3ie?-5ipLine Do nti my3ie?HtEndf-tream myLine=my3ie?eadLine my3ied=-pit(myLine&"&") -ystemti?un "'@A/rogram 3iesAP/Aui+5Test /rofessionaAsampesAfightAappAfight4a?exe" Diaog("text@=Login")?H+ti$ate Diaog("text@=Login")?inEdit("atta+hed text@=Hgent !ame@")?-et my3ied(0) Diaog("text@=Login")?inEdit("atta+hed text@=/ass*ord@")?-et my3ied(%) *ait # Diaog("text@=Login")?inutton("text@=J")?'i+5 indo*("text@=3ight eser$ation")?'ose Loop my3ie?'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- = 'reateb;e+t("-+ripting?3ie-ystemb;e+t") -et rite-tuff = my3-?penText3ie("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 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 hie 3ie%?HtEndf-tream = 3ase -tr% = 3ie%?ead -tr# = 3ie#?ead '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 :sgox "3ies are identi+a?"

2'

Ese :sgox "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MEHDI!6 = % Dim o3so& oTxt3ie& seadTxt& oegEx& 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MEHDI!6) seadTxt = oTxt3ie?eadH -et oegEx = !e* egExp oegEx?/attern = s-tring oegEx?Ignore'ase = bIgnore'ase oegEx?6oba = True -et o:at+hes = oegEx?Exe+ute(seadTxt) :at+hes3ound = o:at+hes?'ount -et oTxt3ie = !othing @ -et o3so = !othing @ -et oegEx = !othing msgbox :at+hes3ound 11) &ead a *SV -ile ;sing 6ata"ase echniIues n Error esume !ext 'onst adpen-tati+ =  'onst adLo+5ptimisti+ =  'onst ad'mdText = .P000% -et ob;'onne+tion = 'reateb;e+t("HDD?'onne+tion") -et ob;e+ord-et = 'reateb;e+t("HDD?e+ordset") str/athtoText3ie = "'@ADatabasesA" ob;'onne+tion?pen "/ro$ider=:i+rosoft?Qet?LED?4?0R" . M "Data -our+e=" . str/athtoText3ie . "R" . M "Extended /roperties=""textRPD=YE-R3:T=Deimited""" ob;e+ordset?pen "-ELE'T 1 3: /honeList?+s$"& M ob;'onne+tion& adpen-tati+& adLo+5ptimisti+& ad'mdText Do nti ob;e+ordset?E3

3!

s+ript?E+ho "!ame@ " . ob;e+ordset?3ieds?Item("!ame") s+ript?E+ho "Department@ " . M  

ob;e+ordset?3ieds?Item("Department") s+ript?E+ho "Extension@ " . ob;e+ordset?3ieds?Item("Extension") ob;e+ordset?:o$e!ext

Loop 1!) &ead a ext -ile into an rray 'onst 3oreading = % -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"& 3oreading) Do nti ob;Text3ie?HtEndf-tream str!extLine = ob;Text3ie?eadine arr-er$i+eList = -pit(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& 3ie%&3ie# 3ie%="'@ADo+uments and -ettingsA% I6PHTHYADes5topAxyF?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. " ytes" 1') 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 6et/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% I6PHTHYADes5topAab+!e*?txt"&#)

31

my3ie?riteLine "'usomer !ames" my3ie?riteLine "CCCCCCCCCCCCCCCCCCCC" If !ot indo*("3ight eser$ation")?Exist() Then -ystemti?un "'@A/rogram 3iesAP/Aui+5Test /rofessionaAsampesAfightAappAfight4a?exe"&""&"'@A/rogram 3iesAP/Aui+5Test /rofessionaAsampesAfightAappA"&"open" Diaog("Login")?H+ti$ate Diaog("Login")?inEdit("Hgent !ame@")?-et "asdf" Diaog("Login")?inEdit("/ass*ord@")?-et-e+ure "4+4B8G0B70499bBd+080bbd#4eB%9BG0+747++fB" Diaog("Login")?inutton("J")?'i+5 End If  3or rderM!umber= % to %0 step % indo*("3ight eser$ation")?H+ti$ate indo*("3ight eser$ation")?inutton("utton")?'i+5 indo*("3ight eser$ation")?Diaog("pen rder")?in'he+5ox("rder !o?")?-et "!" indo*("3ight eser$ation")?Diaog("pen rder")?inEdit("Edit")?-et rderM!umber indo*("3ight eser$ation")?Diaog("pen rder")?inutton("J")?'i+5 'ustomerM!ame = indo*("3ight eser$ation")?inEdit("!ame@")?6et/roperty("text") *ait (#) my3ie?riteLine 'ustomerM!ame !ext my3ie?'ose -et ob;3so=!othing %8) 111111111111111111111111111111111111111111111111111111 est &eIuirementH *apturing all Buttons 9ames from the
View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF