vinodsrivastava.wordpress · vinodsrivastava.wordpress.com sample paper -2 for exam 2016 based on...

25
vinodsrivastava.wordpress.com Sample Paper -2 for Exam 2016 Based on VBSCRIPT & ASP Q4,Q5,Q6 (Total Marks Covered : 30) VBSCRIPT 1. Name the tag and attribute used to add VBscript in HTML Tag <Script> Attribute Language or type 2. Differentiate between Client Side & Server Side Script 3. What is VBScript? VBscript is client side scripting language develop by Microsoft to run on IE only 4. What is Variant Data Type? Name 5 Subtypes Variant is a special data type which can hold any type of data Sub Type of VARIANT: Integer, Byte, Double, Long, String, Date, Currency, Float 5. What is Procedure? Name Two Types of Procedure in VBScript Procedure: it is a grouping of code statements that can be called by an associate name to accomplish certain task. Once Procedure is defined it can be called at different location any number of times 6. What is difference between Sub Procedure and Function

Upload: trankhanh

Post on 23-Apr-2018

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: vinodsrivastava.wordpress · vinodsrivastava.wordpress.com Sample Paper -2 for Exam 2016 Based on VBSCRIPT & ASP Q4,Q5,Q6 (Total Marks Covered : 30) VBSCRIPT 1. Name the tag and attribute

vinodsrivastava.wordpress.com

Sample Paper -2 for Exam 2016Based on VBSCRIPT & ASP

Q4,Q5,Q6 (Total Marks Covered : 30)

VBSCRIPT1. Name the tag and attribute used to add VBscript in HTML

Tag <Script>Attribute Language or type

2. Differentiate between Client Side & Server Side Script

3. What is VBScript?VBscript is client side scripting language develop by Microsoft to run on IE only

4. What is Variant Data Type? Name 5 SubtypesVariant is a special data type which can hold any type of dataSub Type of VARIANT: Integer, Byte, Double, Long, String, Date, Currency, Float

5. What is Procedure? Name Two Types of Procedure in VBScriptProcedure: it is a grouping of code statements that can be called by an associate name toaccomplish certain task. Once Procedure is defined it can be called at different location anynumber of times

6. What is difference between Sub Procedure and Function

Page 2: vinodsrivastava.wordpress · vinodsrivastava.wordpress.com Sample Paper -2 for Exam 2016 Based on VBSCRIPT & ASP Q4,Q5,Q6 (Total Marks Covered : 30) VBSCRIPT 1. Name the tag and attribute

2016-Sample Paper-2

MMWT-SAMPLE PAPERS@ VKS-Learning Hub Page 2

7. What is Argument(Parameter)Argument is used to pass the value from calling function to called function

8. What are different way to call ProcedureThree different way to call procedure (subroutine /function)1. Call Proceurename() using with keyword Call2. Procedurename() simply calling procedure with procedure name with ()3. Procedurename simply calling procedure with procedure name without ()

9. What are comment in VBSCRIPT How can we give comment in VBScriptUse REM or ' in front of each line you wish to comment:

10. Differentiate between Fixed and Dynamic Array with ExampleA fixed array is one that will not change it's size/allocation, while a dynamic array can be reallocated togrow or shrink.

Dynamic array always declare with empty

DYNAMIC ARRAY: dynamic array vary in size depending upon on how many elements are stored in thearray. We can change the no of element by increasing or decreasing it while the code is running.Dynamic array is created without giving the no of elements<Script Language =”VBScript”>Dim name()ReDim name(3)name(0)=”neeraj”name(1)=”dheeraj”name(2)= “madhu”Name(3)= “Shweta”ReDim name(5)name(4)= “Ajay”Name(5)= “Vijay”</script>Fixed array : size of array is given while declaring it. It can holdDim name(3)name(0)=”neeraj”name(1)=”dheeraj”name(2)= “madhu”Name(3)= “Shweta”</script>

11. What is use of Option Explicit statement in VBScriptOption Explicit enforce the use of DIM to declare variable. Any variable declare without Dim will giveerror.

12. What is DIMDIM is used to declare variable explicitly in VBscriptDim AA=10

13.Differentiate Between Local & Global Variable with ExampleLocal Variable Global VariableDeclare inside the Block/Procedure/Function Declare outside any block/Procedure/FunctionAvailable inside the block and block nested blow Available throughout the programLongevity is as long as the block is active Longevity is as long as the program is activeValue updated inside the block only and cannotbe used outside

Value updated inside and outside both and can beused anywhere in script

Page 3: vinodsrivastava.wordpress · vinodsrivastava.wordpress.com Sample Paper -2 for Exam 2016 Based on VBSCRIPT & ASP Q4,Q5,Q6 (Total Marks Covered : 30) VBSCRIPT 1. Name the tag and attribute

2016-Sample Paper-2

MMWT-SAMPLE PAPERS@ VKS-Learning Hub Page 3

14. What is EVENT. What is Event HandlerEvent is a interaction between user and webpage. It triggers when user interact with element of pageEvent Handler is code written specific to particular action by user Like clicking a button or or moving amouse over image

15. Name the Built in Function to do the followingi.To convert expression to integer CIntii.To Convert a Character to Uppercase UCaseiii.To Convert a Character to String CStriv.To return a number to specific decimal places Round (Number, Decimal Places)v.To check String 2 occur within String 1 and return the staring position of String 2 in String 1 InStrvi.To extract the year part of a date. Year(Date)vii.To Reverse a String StrReverse(String)viii.To return the square root of a number. Sqrt(n)ix.To Return Current Date and Time Date()x.To remove the trailing spaces from string Rtrimxi.To Compare Two String StrCompxii.To Return a random Number Rndxiii.To Check Expression is Numeric or not IsNumeric

16. Name the Event which can be used for the followingi.To Display a Message every time viewer closes a webpage OnUnLoadii.To Deactivate a particular textbox from Form f1.t1.disabled=true //f1=forname t1= textbox nameiii.To Perform an action when Button is Pressed OnClickiv.To Perform an action as soon as the content of text box change OnChangev.To Perform an action when the button gain focus OnFocusvi.Extract a portion of a string after specifying the starting position from where the string is to be

extracted and how many characters are to be extracted Mid(String,StartingPoint,N)17. Give the Output

a. Document.write(INSTR(LTRIM(“ WebTech”), “Tech”)) 4b. Document.write(UCASE(RIGHT(“Multimedia”,5))) MEDIAc. Document.Write(ROUND(3/2 + 5*(4-2))) 11d. Document.write (UCASE(MID(“Hello There”),7,3))) THEe. Document.write (MONTHNAME(MONTH(“15-2-2003”))) Feburaryf. Document.write (LTRIM(LEFT(“###Class XII”,6))) Clag. Document.write (LEN(MID(“Multimedia”,4,3))) 3h. Document.write (DAY(“20/4/2005”)) 20i. Document.Write(INSTR(“This is exam”, “his”)) 2j. Document.Write(ROUND(3/2 + 5*(4-2))) 11k. Document.write(UCASE(MID (LTRIM(“####Welcome to Kuwait”), 4,4)) COMEl. Document.Write(ROUND(3+7/2 + 5*(4/2*3\2))) 16m. Document.write ( (LEFT(“###KUWAIT AIRWAYS”, Month(“23-09-2014”)) ###KUWAIT

#indicate space

n. Document.write(INSTR(LTRIM(“##INTERNATIONAL##”), “na”)) 0o. Response.write(STRREVERSE(MONTHNAME(Instr(“Welcome”,“om”))) yaMp. Response.Write (Mid("Welcome to our Site!!”,sqrt(81),2)) toq. Response.Write (Mid("Welcome to our Website !!”,Hour(#11:30:05#), sqrt(49))) #our Si

#indicate spacer. Response.write(Monthname(InStr(“mistrust or DISTRUST” , “ST”))) Errors. Response.write((2^3 < 5 ) AND (8 * 5 / 2 > 21)) False

Page 4: vinodsrivastava.wordpress · vinodsrivastava.wordpress.com Sample Paper -2 for Exam 2016 Based on VBSCRIPT & ASP Q4,Q5,Q6 (Total Marks Covered : 30) VBSCRIPT 1. Name the tag and attribute

2016-Sample Paper-2

MMWT-SAMPLE PAPERS@ VKS-Learning Hub Page 4

18. Give the output of the following code segment:<Script Language=”VBScript”>sometext = “India@”max=Len(sometext)For i=0 to maxnewtext=Left(sometext,i)Document.write(strReverse(newtext))Document.write (“<br>”)next</script>

outputInIdnIidnIaidnI@aidnI

<Script Language=”VBScript”>Dim a, b, suma = 10For b = 1 to 3sum = sum + a + ba = a – bDocument.write(a & “<br>”)NextDocument.write(sum)</Script>

output97432

<Script Language=”VBScript”>A = “54321”max=Len(A)Do While(max>0)B=RIGHT(A,max)Document.write (strReverse(B))Document.write (“<br>”)max=max-1loop</script>

Output123451234123121

<Script Language=”VBScript”>Arr = Array(25,30,45,76)Max = UBound(Arr)For I =Max to 1 Step -1Arr(I) = 100 – Arr(I)NextFor I = 0 to MaxDocument.Write(Arr(I) & “<BR>”)</script>

Output25705524

19. Re-Write the program using Do while without affecting the output<ScriptLanguage=”VBScript”>Dim num , flagFlag=0Num=10For A =2 to Num/2Document.write(“Hello”)Flag=Flag+1Document.write(Flag)Next</script>

OUTPUT<ScriptLanguage=”VBScript”>Dim num , flagFlag=0Num=10A=2Do while (A<=Num/2)Document.write(“Hello”)Flag=Flag+1Document.write(Flag)A=A+1Loop</script>

<ScriptLanguage=”VBScript”>sum=0for I = 0 to 4for j= 0 to i-1select case (i+j-1)case -1,0

sum=sum+1case 1, 2,3

sum=sum+2case else

sum=sum+3end select

nextnext

</script>

OUTPUT<ScriptLanguage=”VBScript”>sum=0i=0Do while(i<=4)J=0Do while(j<=(i-1))select case (i+j-1)case -1,0

sum=sum+1case 1, 2,3

sum=sum+2case else

sum=sum+3end select

looploop</script>

<ScriptLanguage=”VBScript”>s=array(12,45,87,54,90,76)max=ubound(s)for I = max to 1 step -2s(I) = 10*s(I)document.write (arr(I) &

“<br>”)next

</Script>

OUTPUT<ScriptLanguage=”VBScript”>s=array(12,45,87,54,90,76)max=ubound(s)Do while (max >=1)s(I) = 10*s(I)document.write (arr(I) &

“<br>”)max=max-1

loop</Script>

<ScriptLanguage=”VBScript”>Dim prodProd = 1For n = 6 to 1 step – 2prod = prod * 2document.write (prod &“<br>”)Next</Script>

OUTPUT<ScriptLanguage=”VBScript”>Dim prodProd = 1;N=6Do while n>= 1prod = prod * 2document.write (prod &“<br>”)n=n-2loop</Script>

Page 5: vinodsrivastava.wordpress · vinodsrivastava.wordpress.com Sample Paper -2 for Exam 2016 Based on VBSCRIPT & ASP Q4,Q5,Q6 (Total Marks Covered : 30) VBSCRIPT 1. Name the tag and attribute

2016-Sample Paper-2

MMWT-SAMPLE PAPERS@ VKS-Learning Hub Page 5

<Scriptlanguage="VBScript">str ="Multimedia and WebTech"For i=5 to Len(str) step 3Document.Write(Left(str,i))Next</script>

Output<Scriptlanguage="VBScript">str ="Multimedia and WebTech"i=5do while i<= Len(str)Document.Write(Left(str,i))i=i+3loop</script>

<Script language="VBScript">arr=array(25,12,36,65,69,62,21,14,15,36)

max=ubound(arr)for I = max to 1 step -3arr(i)=abs(50-arr(i))Document.write(arr(i) & “<br>”)Next </script>

output<Script language="VBScript">arr=array(25,12,36,65,69,62,21,14,15,36)max=ubound(arr)do while max>=1

arr(i)=abs(50-arr(i))Document.write(arr(i) & “<br>”)

max=max-3loop </script>

20. Re-Write the program using For… Next without affecting the output<ScriptLanguage=”VBScript”>A = “54321”max=Len(A)Do While(max>0)B=RIGHT(A,max)Document.write(strReverse(B))Document.write (“<br>”)max=max-1loop</script>

<ScriptLanguage=”VBScript”>A = “54321”max=Len(A)for max to 1 step-1B=RIGHT(A,max)Document.write(strReverse(B))Document.write(“<br>”)next</script>

<ScriptLanguage=”VBSCRIPT”>A=array(10,20,30,40,50,60)max=ubound(A)do while(i<=max)A(i)= A(i)\3i=i+2Document.Write(A(i))loop

</Script>

Output<ScriptLanguage=”VBSCRIPT”>A=array(10,20,30,40,50,60)max=ubound(A)for i=1 to max step 2A(i)= A(i)\3Document.Write(A(i))Next

</Script>

<ScriptLanguage=”VBScript”>Dim a, b, suma = 10b=1do while ( b <= 6 )sum = sum + a + ba = a – bDocument.write(a &“<br>”)b=b+2loopDocument.write(sum)</Script>

OUTPUT<ScriptLanguage=”VBScript”>Dim a, b, suma = 10for b=1 to 6 step 2sum = sum + a + ba = a – bDocument.write(a &“<br>”)nextDocument.write(sum)</Script>

<scriptlanguage="VBScript">sub result()dim i,r,rev,kk=4320100do whilek<12000000r=k mod 10k=k+50000loopend sub</script>

OUTPUT<scriptlanguage="VBScript">sub result()dim i,r,rev,kfor k=4320100 to1200000step 50000r=k mod 10Nextend sub</script>

Page 6: vinodsrivastava.wordpress · vinodsrivastava.wordpress.com Sample Paper -2 for Exam 2016 Based on VBSCRIPT & ASP Q4,Q5,Q6 (Total Marks Covered : 30) VBSCRIPT 1. Name the tag and attribute

2016-Sample Paper-2

MMWT-SAMPLE PAPERS@ VKS-Learning Hub Page 6

21.Underline the Error and re-write corrected code<Script Text=”VBscript”>sub result()dim n1,n2,sumn1=5n2 =10for i=n1 upto n2 skip 2if n1>n2 thenn1+n2=sumnextend sub</Script>

Corrected code<Scriptlanguage=”VBscript”>sub result()dim n1,n2,sumn1=5n2 =10for i=n1 to n2 step 2if n1>n2 thensum= n1+n2nextend sub</Script>

<Script Language>option explicitdim arr(8),maxarr=array(25,14,20,45,25,4,1,31)max=upbound(arr)for i=max to 1 go -2arr(i)*10= arr(i)document.write (arr(i) & “<br>” )loop</Script>Corrected code<Script Language=”VBSCRIPT”>option explicitdim arr(8),maxarr=array(25,14,20,45,25,4,1,31)max=upbound(arr)for i=max to 1 step -2arr(i)= arr(i)*10document.write (arr(i) & “<br>” )next</Script>

<Script Language=“VBScript”>s= “Dynamic Array”

for I = 1 upto 7 skip 2n=mid(s,I,2)response.write (n)document .write(“<br>”)loop<Script>

Corrected code<Script Language=“VBScript”>s= “Dynamic Array”

for I = 1 to 7 step 2n=mid(s,I,2)response.write (n)document .write(“<br>”)next<Script>

<script type=”vbscript”>sub totaljdefine totalfor j = 2 till 10 step 2total = total + jnextmessage (“the total is:”& total)end subcall totalj</script>Corrected code<script type=”text\vbscript”>sub totalj()dim totalfor j = 2 to 10 step 2total = total + jnextMessageBox(“the total is:”& total)end sub</script>call totalj

Page 7: vinodsrivastava.wordpress · vinodsrivastava.wordpress.com Sample Paper -2 for Exam 2016 Based on VBSCRIPT & ASP Q4,Q5,Q6 (Total Marks Covered : 30) VBSCRIPT 1. Name the tag and attribute

2016-Sample Paper-2

MMWT-SAMPLE PAPERS@ VKS-Learning Hub Page 7

22. EVENT HANDLINGA) Write a VBScript Code to get user input two string in two textboxes and show. The reverse of

combined string in third box on the click of button 3

String1 String 2 String 3

<html><head><Script Language= “VBScript”>Sub b1_OnclickN1=F1.T1.ValueN2=F1.T2.ValueF1.T3.Value=StrReverse(N1+n2)End Sub</Script></head><Body ><Form name= “F1”>String1 <Input type= “text” name= “T1”>String2 <Input type= “text” name= “T2”>String3 <Input type= “text” name= “T3”><Input type= “Button” name= “b1” value= “Join+Reverse></Form></body></html>

B) Write the code to display the below form and add the vbscript to display the results as written 4when user enters salary and click on calculate bonus button.

If salary is >=25000, Bonus is 5% of salaryIf salary is >=15000, Bonus is 3% of salaryIf salary is < 15000, No Bonus

<html><head><Script Language= “VBScript”>Sub b1_OnclickF1.T1.Value=now()F1.T2.Value=WeekdayName(Weekday(Day(Date()))N1=F1.T3.ValueIf N1>=25000 thenF1.T4.Value=0.05*250000Elseif N1>=15000 AND N1<25000 thenF1.T4.Value=0.03*250000ElseF1.T4.Value=”No Bonus”End ifEnd Sub</Script></head>

Good Luck kcuLdooG Join+Reverse

Page 8: vinodsrivastava.wordpress · vinodsrivastava.wordpress.com Sample Paper -2 for Exam 2016 Based on VBSCRIPT & ASP Q4,Q5,Q6 (Total Marks Covered : 30) VBSCRIPT 1. Name the tag and attribute

2016-Sample Paper-2

MMWT-SAMPLE PAPERS@ VKS-Learning Hub Page 8

<Body ><Form name= “F1”>Date & Time<Input type= “text” name= “T1”> <Br>Weekday Name <Input type= “text” name= “T2”>Your Salary <Input type= “text” name= “T3”>Your Bonus <Input type= “text” name= “T4”><Input type= “Reset” name= “re1” value= “Clear All”><Input type= “Button” name= “b1” value= “Calculate Bonus”></Form></body></html>

C) Write the code to display the below form and add the vbscript to display the results as writtenwhen user enter no and click on button. <4><html><head><Script Language= “VBScript”>Sub b1_OnclickF1.T1.Value=Year(Date)F1.T2.Value=MonthName(Month(Date()))N1=F1.T3.ValueIf N1 MOD 2=0 thenF1.T4.Value=EVEN NUMBERElseF1.T4.Value=”ODD NUMBER”End ifEnd Sub</Script></head><Body ><Form name= “F1”>Current Year<Input type= “text” name= “T1”> <Br>Month Name <Input type= “text” name= “T2”>Even No <Input type= “text” name= “T3”>Even/Odd <Input type= “text” name= “T4”><Input type= “Button” name= “b1” value= “Click”></Form></body></html>

D) Write the HTML code to generate the following form : <4>Write the VBScript code to display the PTM

date on the click of the GET PTM DATE button as :- 12/10/2012 if class entered is between 1to 6 and- 15/10/2012 if class is between 7 to 12- If the user enters any class other thanthe above then an error message shouldbe displayed.

Page 9: vinodsrivastava.wordpress · vinodsrivastava.wordpress.com Sample Paper -2 for Exam 2016 Based on VBSCRIPT & ASP Q4,Q5,Q6 (Total Marks Covered : 30) VBSCRIPT 1. Name the tag and attribute

2016-Sample Paper-2

MMWT-SAMPLE PAPERS@ VKS-Learning Hub Page 9

<html><head><Script Language= “VBScript”>Sub b1_OnclickN1=F1.T1.ValueIf N1 >=1 AND N1<=6 thenF1.T4.Value= “12/10/2012Elseif N1 >=7 AND N1<=12 thenF1.T4.Value= “15/10/2012ElseF1.T4.Value= “Wrong Class, Entereen Class between 1 to 12”End ifEnd Sub</Script></head><Body ><Form name= “F1”>Enter Class of Your Ward<Input type= “text” name= “T1”> <Br>PTM Date <Input type= “text” name= “T2”><Input type= “Button” name= “b1” value= “GET PTM DATE”></Form></body></html>

E) Write the HTML code for creating the form given below and also write the embedded VBScriptcode for the click event of the submit button, such that it displays a message with the nameentered by the user and amount of his bill. The costs are given below :

Regular Pizza : Rs. 200Pan Pizza : Rs. 250The toppings cost extra :Cheese Topping : Rs. 80Capsicum Topping : Rs. 95Peperoni Topping : Rs. 70

If the user enters name as “Umang” and selects “Pan” andtopping as “Cheese” then it should display the message“Dear Umang ! Your bill amount is Rs. 330” in a message box.

<html><head> <Title> Bill</title><script language="Vbscript">Sub B1_OnClick()Dim N,P,Cost,TC, top,TN=document.f1.t1.valueif document.f1.R1(0).checked thenP=document.f1.R1(0).valueCost=200end ifif document.f1.R1(1).checked thenP=document.f1.R1(1).valueCost=250end if

Page 10: vinodsrivastava.wordpress · vinodsrivastava.wordpress.com Sample Paper -2 for Exam 2016 Based on VBSCRIPT & ASP Q4,Q5,Q6 (Total Marks Covered : 30) VBSCRIPT 1. Name the tag and attribute

2016-Sample Paper-2

MMWT-SAMPLE PAPERS@ VKS-Learning Hub Page 10

1

T=document.f1.S1.selectedindexif T=0 thenTT=document.f1.S1(0).valuetop=60elseif T=1 thenTT=document.f1.S1(1).valuetop=75elseTT=document.f1.S1(2).valuetop=100end ifTC=Cost+topMsgbox(" Dear "& N &chr(13) & " You have Selected The Follwoing Item" &Chr(13) & "Piza type=" & P&Chr(13) & "Topping Type=" & TT &Chr(13) & "Your Bill is=" & TC)End Sub</Script></head><Body Bgcolor="Yellow"><H1> YUMMY PIZZA</H1><Form Name="f1">Customer Name:<Input Type="Text" Name="t1"><br>Select Pizza :<Input Type="Radio" Name="R1" Value="Reg">Regular <Input Type="Radio" Name="R1"Value="Pan"> Pan<br>Select Topping:<select Name="S1" ><option value="Cheese"> Cheese</Option><option value="Capsicum"> Capsicum</Option><option value="Pepproni">Peproni</Option></Select><br><Input Type="Button" Name="B1" Value="Calculate"></form></Body></html>

F) Write an HTML (VBSCRIPT) code for creating a form, which contains five textboxes as shownbelow. The first textbox accept travel code and second textbox accept number of adults and thirdtext box accepts number of children ,forth text box accepts distance in KM .. In the fifth textboxcalculate total fare as follows

for each childthe aboveFare will be50% of theFarementioned in the above tablefor example if the distance is 750, no_of_adults=3and no-of_children=2 then the total fare should becalculated asno_of_adults*300+no_of_children*150i.e 3*300+2*150 = 1200

Fare(Rs)For Adults

For Distance (Km)

500 >=1000300 <1000 &>=500200 <500

Page 11: vinodsrivastava.wordpress · vinodsrivastava.wordpress.com Sample Paper -2 for Exam 2016 Based on VBSCRIPT & ASP Q4,Q5,Q6 (Total Marks Covered : 30) VBSCRIPT 1. Name the tag and attribute

2016-Sample Paper-2

MMWT-SAMPLE PAPERS@ VKS-Learning Hub Page 11

<html><head><Script Language= “VBScript”>Sub b1_OnclickN1=F1.T1.ValueN2=F1.T2.ValueN3=F1.T3.ValueN4=F1.T4.ValueIf N4>=1000 thenF1.T5.value=N2*500+N3*250Elseif N4>=500 AND N4<1000 thenF1.T5.value=N2*300+N3*150ElseF1.T5.value=N2*200+N3*100End ifEnd Sub</Script></head><Body ><Form name= “F1”>T_Code<Input type= “text” name= “T1”> <Br>No of Adults <Input type= “text” name= “T2”> <Br>No of Children <Input type= “text” name= “T3”> <Br>Distance <Input type= “text” name= “T4”> <Br>TotalFare<Input type= “text” name= “T5”> <Br><Br><Input type= “Button” name= “b1” value= “Calculate Fare”></Form></body></html>

G) Write the HTML code for creating the form given below and also write the embedded VBScriptcode for the click event of the “Calculate Cost” button,should call a function “calculate()” which willcalculate the total cost of theitems bought anddisplays it in an message box. For example if theuserselects T-Shirt as the item and enters thenumber of items as 2 then the total cost will be Rs.600.

<html><head><Script Language= “VBScript”>Sub b1_OnclickN1=F1.S1.SelectedIndexN2=F1.T1.ValueIf N1=0 thenCost=600Elseif N1=1 thenCost=300ElseCost=900End if

Page 12: vinodsrivastava.wordpress · vinodsrivastava.wordpress.com Sample Paper -2 for Exam 2016 Based on VBSCRIPT & ASP Q4,Q5,Q6 (Total Marks Covered : 30) VBSCRIPT 1. Name the tag and attribute

2016-Sample Paper-2

MMWT-SAMPLE PAPERS@ VKS-Learning Hub Page 12

TC=Cost*N2Msgbox(“Total Cost =” & TC)End Sub</Script></head><Body ><H1 Align = “Center”> Online Shopping</H1><Form name= “F1”>Select Your Choice(Any One):<Select name= “S1”><Option Value= “Shirt”> Shirt Rs. 600</option><Option Value= “T-Shirt”> T-Shirt Rs. 300</option><Option Value= “Trousers”> Trousers Rs. 900</option></Select><br>Enter Number of Items you want <Input type= “text” name= “T1”> <Br><Input type= “Button” name= “b1” value= “Calculate Cost”></Form></body></html>

H) Write an HTML code for creating a form, which contains three textboxes as shown below. Thefirst two textboxes accept two numbers as input from theuser and the third textbox displays the sum of these twonumbers. Include the VBScript code which contains a user-defined function required to be called when the userchanges the values in any of the first two text boxes.

<HTML><HEAD><TITLE>Button Event</TITLE><SCRIPT LANGUAGE=”VBScript”>Sub calcc1=cDbl(document.form1.txt1.value)c2=cDbl(document.form1.txt2.value)c3=c1+c2document.form1.txt3.value =c3End Sub</SCRIPT><HEAD><BODY LANGUAGE=”VBScript”><FORM NAME=”form1"><H4>Enter numbers into the first two text boxes to find their sum</H4><INPUT TYPE=”text” value=0 NAME=”txt1" size=5 onChange=‟calc‟>+ <INPUT TYPE=”text” value=0 NAME=”txt2" size=5 onChange=‟calc‟>

= <INPUT TYPE=”text” value=0 NAME=”txt3" size=6></FORM></BODY></HTML>

Page 13: vinodsrivastava.wordpress · vinodsrivastava.wordpress.com Sample Paper -2 for Exam 2016 Based on VBSCRIPT & ASP Q4,Q5,Q6 (Total Marks Covered : 30) VBSCRIPT 1. Name the tag and attribute

2016-Sample Paper-2

MMWT-SAMPLE PAPERS@ VKS-Learning Hub Page 13

I) Create a form that contains two checkbox options and a textbox as shown below.When the user clicks onany checkbox the selected options must be displayed in thetextbox. Write the HTML code for creating theform and the embedded VBScriptcode for the click events of the checkboxes.

<HTML> <HEAD><SCRIPT LANGUAGE=”VBScript”>Sub ShowResults()Dim ResultIf chkmovie.Checked ThenResult = Result &“ movies “End IfIf chkbook.Checked ThenResult = Result &“ books “End IftxtResult.Value = ResultEnd sub</SCRIPT> </HEAD><BODY>

<form name=”frm”><H4>The Check Box Control - Click on a check box.</H4><P>Please select the categories that interest you.<BR><INPUT TYPE=”checkbox” NAME=”chkmovie”OncLICK=”ShowResults”> Movies<BR><INPUT TYPE=”checkbox” NAME=”chkbook” OncLICK=”ShowResults”>Books<BR><P><INPUT NAME=”txtResult” SIZE=”60"></form> </BODY> </HTML>

J) Write HTML document to create the following formand Use VB Script to find out the division secured by astudent on the basis of the % of marks obtained in theexamination. The student is failed if the marks arebelow 33%, he secures a III division if the marks are33% onwards but below 50%, a II division if he secures50% onwards but below 60%, a I division if he secures60% onwards but below 75% and a Distinction if thescore is 75% and onwards<HTML>

<html><HEAD><SCRIPT LANGUAGE=”VBScript”>Sub B1_OnclickDIM GradeIF document.frml.txtl.value>=75 THENGrade=”Distinction”ELSEIF document.frml.txtl.value>=60 THENGrade=”I Division”ELSEIF document.frml.txtl.value>=50 THENGrade=”II Division”ELSEIF document.frml.txtl.value>=33 THEN

2016-Sample Paper-2

MMWT-SAMPLE PAPERS@ VKS-Learning Hub Page 13

I) Create a form that contains two checkbox options and a textbox as shown below.When the user clicks onany checkbox the selected options must be displayed in thetextbox. Write the HTML code for creating theform and the embedded VBScriptcode for the click events of the checkboxes.

<HTML> <HEAD><SCRIPT LANGUAGE=”VBScript”>Sub ShowResults()Dim ResultIf chkmovie.Checked ThenResult = Result &“ movies “End IfIf chkbook.Checked ThenResult = Result &“ books “End IftxtResult.Value = ResultEnd sub</SCRIPT> </HEAD><BODY>

<form name=”frm”><H4>The Check Box Control - Click on a check box.</H4><P>Please select the categories that interest you.<BR><INPUT TYPE=”checkbox” NAME=”chkmovie”OncLICK=”ShowResults”> Movies<BR><INPUT TYPE=”checkbox” NAME=”chkbook” OncLICK=”ShowResults”>Books<BR><P><INPUT NAME=”txtResult” SIZE=”60"></form> </BODY> </HTML>

J) Write HTML document to create the following formand Use VB Script to find out the division secured by astudent on the basis of the % of marks obtained in theexamination. The student is failed if the marks arebelow 33%, he secures a III division if the marks are33% onwards but below 50%, a II division if he secures50% onwards but below 60%, a I division if he secures60% onwards but below 75% and a Distinction if thescore is 75% and onwards<HTML>

<html><HEAD><SCRIPT LANGUAGE=”VBScript”>Sub B1_OnclickDIM GradeIF document.frml.txtl.value>=75 THENGrade=”Distinction”ELSEIF document.frml.txtl.value>=60 THENGrade=”I Division”ELSEIF document.frml.txtl.value>=50 THENGrade=”II Division”ELSEIF document.frml.txtl.value>=33 THEN

2016-Sample Paper-2

MMWT-SAMPLE PAPERS@ VKS-Learning Hub Page 13

I) Create a form that contains two checkbox options and a textbox as shown below.When the user clicks onany checkbox the selected options must be displayed in thetextbox. Write the HTML code for creating theform and the embedded VBScriptcode for the click events of the checkboxes.

<HTML> <HEAD><SCRIPT LANGUAGE=”VBScript”>Sub ShowResults()Dim ResultIf chkmovie.Checked ThenResult = Result &“ movies “End IfIf chkbook.Checked ThenResult = Result &“ books “End IftxtResult.Value = ResultEnd sub</SCRIPT> </HEAD><BODY>

<form name=”frm”><H4>The Check Box Control - Click on a check box.</H4><P>Please select the categories that interest you.<BR><INPUT TYPE=”checkbox” NAME=”chkmovie”OncLICK=”ShowResults”> Movies<BR><INPUT TYPE=”checkbox” NAME=”chkbook” OncLICK=”ShowResults”>Books<BR><P><INPUT NAME=”txtResult” SIZE=”60"></form> </BODY> </HTML>

J) Write HTML document to create the following formand Use VB Script to find out the division secured by astudent on the basis of the % of marks obtained in theexamination. The student is failed if the marks arebelow 33%, he secures a III division if the marks are33% onwards but below 50%, a II division if he secures50% onwards but below 60%, a I division if he secures60% onwards but below 75% and a Distinction if thescore is 75% and onwards<HTML>

<html><HEAD><SCRIPT LANGUAGE=”VBScript”>Sub B1_OnclickDIM GradeIF document.frml.txtl.value>=75 THENGrade=”Distinction”ELSEIF document.frml.txtl.value>=60 THENGrade=”I Division”ELSEIF document.frml.txtl.value>=50 THENGrade=”II Division”ELSEIF document.frml.txtl.value>=33 THEN

Page 14: vinodsrivastava.wordpress · vinodsrivastava.wordpress.com Sample Paper -2 for Exam 2016 Based on VBSCRIPT & ASP Q4,Q5,Q6 (Total Marks Covered : 30) VBSCRIPT 1. Name the tag and attribute

2016-Sample Paper-2

MMWT-SAMPLE PAPERS@ VKS-Learning Hub Page 14

Grade=”III Division”ELSEGrade=”Failed”END IFDocument.frml.txt2.value=GradeEnd Sub</SCRIPT> </HEAD><BODF><FORM NAME=”frml”><P> Calculate your division</P><P> Enter your percentage<INPUT TYPE=”text” NAME=”txtl”><BR>Grade <INPTUT TYPE=’’text” NAME=”txt2"><BR><INPTUT TYPE=’’Button” NAME=”B1" Value=”Calculate”><BR></P></FORM> </BODY> </HTML>

K) Create a Form as given below and write Vbscript code to generate Event on click of calculatebutton

<HTML><HEAD><SCRIPT LANGUAGE =”VBSCRIPT”>Sub B1_OnClickP=CInt(f1.Txt1.value)R=CInt(f1.Txt2.value)T=CInt(f1.Txt3.value)SI=(P*R*T)/100f1.Txt4.value=SIEnd Sub</SCRIPT></HEAD><BODY><form ="f1"><h1 align="Center"> SIMPLE INTEREST</H1>Pricipal : <input type= "text" name= "Txt1"><Br>Rate : <input type= text name= "Txt2"><Br>Time : <input type= text name= "Txt3"><Br>Simple Interest : <input type= text name= "Txt4"><Br><input type=Button Name="B1" Value= "Calculate"></form></BODY></HTML>

2016-Sample Paper-2

MMWT-SAMPLE PAPERS@ VKS-Learning Hub Page 14

Grade=”III Division”ELSEGrade=”Failed”END IFDocument.frml.txt2.value=GradeEnd Sub</SCRIPT> </HEAD><BODF><FORM NAME=”frml”><P> Calculate your division</P><P> Enter your percentage<INPUT TYPE=”text” NAME=”txtl”><BR>Grade <INPTUT TYPE=’’text” NAME=”txt2"><BR><INPTUT TYPE=’’Button” NAME=”B1" Value=”Calculate”><BR></P></FORM> </BODY> </HTML>

K) Create a Form as given below and write Vbscript code to generate Event on click of calculatebutton

<HTML><HEAD><SCRIPT LANGUAGE =”VBSCRIPT”>Sub B1_OnClickP=CInt(f1.Txt1.value)R=CInt(f1.Txt2.value)T=CInt(f1.Txt3.value)SI=(P*R*T)/100f1.Txt4.value=SIEnd Sub</SCRIPT></HEAD><BODY><form ="f1"><h1 align="Center"> SIMPLE INTEREST</H1>Pricipal : <input type= "text" name= "Txt1"><Br>Rate : <input type= text name= "Txt2"><Br>Time : <input type= text name= "Txt3"><Br>Simple Interest : <input type= text name= "Txt4"><Br><input type=Button Name="B1" Value= "Calculate"></form></BODY></HTML>

2016-Sample Paper-2

MMWT-SAMPLE PAPERS@ VKS-Learning Hub Page 14

Grade=”III Division”ELSEGrade=”Failed”END IFDocument.frml.txt2.value=GradeEnd Sub</SCRIPT> </HEAD><BODF><FORM NAME=”frml”><P> Calculate your division</P><P> Enter your percentage<INPUT TYPE=”text” NAME=”txtl”><BR>Grade <INPTUT TYPE=’’text” NAME=”txt2"><BR><INPTUT TYPE=’’Button” NAME=”B1" Value=”Calculate”><BR></P></FORM> </BODY> </HTML>

K) Create a Form as given below and write Vbscript code to generate Event on click of calculatebutton

<HTML><HEAD><SCRIPT LANGUAGE =”VBSCRIPT”>Sub B1_OnClickP=CInt(f1.Txt1.value)R=CInt(f1.Txt2.value)T=CInt(f1.Txt3.value)SI=(P*R*T)/100f1.Txt4.value=SIEnd Sub</SCRIPT></HEAD><BODY><form ="f1"><h1 align="Center"> SIMPLE INTEREST</H1>Pricipal : <input type= "text" name= "Txt1"><Br>Rate : <input type= text name= "Txt2"><Br>Time : <input type= text name= "Txt3"><Br>Simple Interest : <input type= text name= "Txt4"><Br><input type=Button Name="B1" Value= "Calculate"></form></BODY></HTML>

Page 15: vinodsrivastava.wordpress · vinodsrivastava.wordpress.com Sample Paper -2 for Exam 2016 Based on VBSCRIPT & ASP Q4,Q5,Q6 (Total Marks Covered : 30) VBSCRIPT 1. Name the tag and attribute

2016-Sample Paper-2

MMWT-SAMPLE PAPERS@ VKS-Learning Hub Page 15

ASP

1. What is ASP Name two Equivalent TechnologyAn Active Server Page is a standard HTML page that has been extended with server-side scripts,objects, and components. By using Active Server Pages, we can create Web sites with dynamiccontent. Equivalent Technologies are PHP JAVASCRIPT CGI, PERL CODE FUSION

2. What is a Web Server? Name Two Web server used for ASP ?Web Server is a server engine. It provides the methods and properties that enables a ASP code tocommunicate with the engine. Two Web Server : PWS (Personal Web Server) & IIS(InternetInformation Server)

3. What is Ad rotator Component Name Two Properties and Method used to create Ad RotatorThe Ad Rotator component display an advertisement for Web page each time the user refreshes orloads the Web page. Two files are required to set up the Ad Rotator component: an Ad RotatorInclude file and an ad images data file.Methods: getadvertismentProperties : Target / Clickable / Width / Height

4. What is Component Rotator Name two Method of Component RotatorThe Component Rotator display html content for Web page each time the user refreshes or loadsthe Web page. Two files are required to set up the Component rotator: an Component rotatorInclude file and Content Scheduler file.Methods: ChooseContent / Getallcontent

5. Difference Between GetAdvertisement & ChoosecontentGetAdvertisement Choosecontent

The GetAdvertisement method retrieves the nextadvertisement from the Rotator Schedule file. Eachtime the script is run, such as when a user opens orrefreshes a page.

The ChooseContent method retrieves an newHTML content string from the ContentSchedule file and displays it on the currentpage. each time the script is run, such as whena user opens or reloads a page.

It is a method of Ad Rotator Component It is a method of Content rotator Component

6. What is Page Counter Component Name Three MethodsThe Page Counter component creates a PageCounter object that counts and displays the number oftimes a Web page has been opened. Methods are1.Hits() method returns the number of times that a specified Web page has been opened.2 PageHit() method increments the hit count for the current Web page.3.Reset() method sets the hit count for a specified Web page to 0.

7. What is Global.asa Give Structure of Global.asa fileThe Global.asa file is an optional file in which you can specify event scripts and declare objects thathave session or application scope. It is not a content file displayed to the users; instead it storesevent information and objects used globally by the application.

Page 16: vinodsrivastava.wordpress · vinodsrivastava.wordpress.com Sample Paper -2 for Exam 2016 Based on VBSCRIPT & ASP Q4,Q5,Q6 (Total Marks Covered : 30) VBSCRIPT 1. Name the tag and attribute

2016-Sample Paper-2

MMWT-SAMPLE PAPERS@ VKS-Learning Hub Page 16

8. How the Application_OnEnd is different from Session_OnEnd event ?Application_OnEnd Application_OnStartThe Application_OnEnd event occurs when theapplication quits, after the Session_OnEnd event.

The Application_OnStart event occurs before thefirst new session is created, that is, before theSession_OnStart event.

<SCRIPT LANGUAGE=ScriptLanguageRUNAT=Server>Sub Application_OnEnd. . .End Sub</SCRIPT>

<SCRIPT LANGUAGE=ScriptLanguageRUNAT=Server>Sub Application_OnStart. . .End Sub</SCRIPT>

9. Explain the following MethodsLockApplication object

The Lock method blocks other clients from modifying the variables stored in theApplication object, ensuring that only one client at a time can alter or access theApplication variables. Needs to be explicitly called.<% Response.lock %>

UnLockApplication object

The Unlock method allows other clients to modify Application object properties.The web server unlocks the Application object when the asp file ends or times out.

ClearResponse object

Erases any buffered HTML output. Clear method only erases the response body; itdoes not erase response headers. Eg: <% Response.Clear %>

EndResponse object

The End method causes the Web server to stop processing the script and returnthe current result. The remaining contents of the file are not processedEg <% Response.end %>

FlushResponse object

The Flush method sends buffered output immediately. This method will cause arun-time error if Response.Buffer has not been set to TRUE.

Eg <% Response.flush %>RedirectResponse object

Sends a redirect message to the browser, causing it to attempt to connect to adifferent URL. Eg <% Response.Redirect URL %>

WriteResponse object

Writes a variable to the current HTTP output as a string.<% Response.Write "Hello World." %>

10. Explain following Collection of Request Object

Form CollectionThe Form collection retrieves the values of form elements posted to the HTTPrequest body by a form using the POST method.

QueryString

Collection

The QueryString collection retrieves the values of the variables in the HTTP querystring. The HTTP query string is specified by the values following the questionmark (?). Several different processes can generate a query string. For example,the anchor tag

Cookies collectionThe Cookies collection enables you to retrieve the values of the cookies sent in anHTTP request.

11. What is PermissionChecker objectThe Permission Checker component creates a PermissionChecker object that uses the passwordauthentication protocols provided in Microsoft® Internet Information Server (IIS) to determine whethera Web user has been granted permissions to read a file.

Page 17: vinodsrivastava.wordpress · vinodsrivastava.wordpress.com Sample Paper -2 for Exam 2016 Based on VBSCRIPT & ASP Q4,Q5,Q6 (Total Marks Covered : 30) VBSCRIPT 1. Name the tag and attribute

2016-Sample Paper-2

MMWT-SAMPLE PAPERS@ VKS-Learning Hub Page 17

12. Name and explain different ServerVariableThe ServerVariables collection retrieves the values of predetermined environment variables.REMOTE_ADDR:REMOTE_HOST:REMOTE_USER:SERVER_NAME

The IP address of the remote host making the request.<%= Request.ServerVariables("REMOTE_ADDR") %>

The name of the host making the request. If the server does not have thisinformation, it will set REMOTE_ADDR and leave this empty.<%= Request.ServerVariables("REMOTE_HOST") %>

Unmapped user-name string sent in by the User.<%= Request.ServerVariables("REMOTE_USER ") %>

The server's host name, DNS alias, or IP address as it would appear in self-referencing URLs<%= Request.ServerVariables("SERVER_NAME") %>

13. Differentiate between Application and Server object of ASPApplication object Server object

Application object store & share informationamong all users of a given application

Session object store information needed for aparticular user-session

Lock and Unlock methods of Application Objecttoensure that multiple users do not try to alter aproperty simultaneously.

The Abandon method of Session Objectdestroys all the objects stored in a Sessionobject and releases their resources

14. Difference Between Response & Request ObjectResponse Object Request Object

Used to send data from the browser Used to send information from the server to the browsExample. I) query stringii) formiii) cookies

Example i) write methodii) flush methodiii) end method

15. Name objects required to manage database through ASP.Two Objects required to manage database through Asp areADOBD.ConnectionADODB.Recordset

16. What is ADO ? What is the significance of OLEDB with reference to ADO in ASP?ADO: “active data object” An ADO can be used within ASP to access a database and make the webbrowser to act as an interface between data and the end userOLE DB. It provide a system level interface to a data source.

17. What is use of Record Set Object?A Record Set Object is used to collect records or data retrieved from a database. The database couldbe MS Access or MySQL. Before retrieving the records set, a connection to the database is openedusing ADO object.

18. Differentiate between optimistic and pessimistic locking of a record set.Optimistic locking Pessimistic lockinglocking record by record. the providerlock records only when calling updateMethod.

locking record by record the provider lockrecords immediately after editing.

Page 18: vinodsrivastava.wordpress · vinodsrivastava.wordpress.com Sample Paper -2 for Exam 2016 Based on VBSCRIPT & ASP Q4,Q5,Q6 (Total Marks Covered : 30) VBSCRIPT 1. Name the tag and attribute

2016-Sample Paper-2

MMWT-SAMPLE PAPERS@ VKS-Learning Hub Page 18

19. Difference Between AtEndOfLine & AtEndOfStreamAtEndOfLine AtEndOfStreamReturns true if the file pointer is positionedimmediately before the end-of line marker in aTextStream file, and false if not

Returns true if the file pointer is at the end of aTextStream file, and false if not

20. Explain the methods of textstream ObjectMethod DescriptionClose Closes an open TextStream fileRead Reads a specified number of characters from a TextStream file and returns the

resultReadAll Reads an entire TextStream file and returns the resultReadLine Reads one line from a TextStream file and returns the resultSkip Skips a specified number of characters when reading a TextStream fileSkipLine Skips the next line when reading a TextStream fileWrite Writes a specified text to a TextStream fileWriteLine Writes a specified text and a new-line character to a TextStream fileWriteBlankLines Writes a specified number of new-line character to a TextStream file

21.Explain the Methods of FileSystem ObjectMethod DescriptionOpenTextFile Opens a file and returns a TextStream object that can be used to access the fileCreatTextFile Creates a text file and returns a TextStream object that can be used to read

from, or write to the fileFileExists Checks if a specified file exists

22.Two Ways to open the Database using ADOUsing Connection string & DSN(Data Source Name) are two ways to open Database

23.Explain the Methods of Recordset ObjectMethod DescriptionMove(n) Move the Cursor to n recordsMoveFirst Move to the Cursor to First Records of RecordsetMoveLast Move to the Cursor to Last Records of RecordsetMovePrevious Move to the Cursor to Previous Records of RecordsetMoveNext Move to the Cursor to Next Records of RecordsetAddnew Add a blank record to Recordset to add new recordUpdate It Saves the record on Database from RecordsetDelete It is used to delete records from the database table.

24. Explain AdOpenDynamic & AdOpenKeyset CursorMethod DescriptionAdOpenDynamic(2)

A dynamic cursor with both forward and backward scrolling where additions,deletions, insertions, and updates made by other users are visible

AdOpenKeyset(1) A keyset cursor allows you to see dynamic changes to a specific group ofrecords but you cannot see new records added by other users

Page 19: vinodsrivastava.wordpress · vinodsrivastava.wordpress.com Sample Paper -2 for Exam 2016 Based on VBSCRIPT & ASP Q4,Q5,Q6 (Total Marks Covered : 30) VBSCRIPT 1. Name the tag and attribute

2016-Sample Paper-2

MMWT-SAMPLE PAPERS@ VKS-Learning Hub Page 19

25. Questions given below are based on ASP advance programming :a) Read the following code carefully

<%Response.Buffer=True%><% Response.write(“1. II cycle test paper”)

Response.write(“2. ASP”)Response.write(“3.All the best”)Response.write(“4. Illusion of knowledge is not education, but ignorance. Foolish people havea strange kind of confidence which comes only with ignorance.”)Response.write(“5. Do your best!”)Response.write(“6. Being ignorant is not so much a shame as being unwilling to learn to dothings the right way.”) %>

i. Place end, clear and flush methods of response object in such a way so that it only display3th and 5th point.

<%Response.Buffer=True%><% Response.write(“1. II cycle test paper”)

Response.write(“2. ASP”)Response.ClearResponse.write(“3.All the best”)Response.FlushResponse.write(“4. Illusion of knowledge is not education, but ignorance. Foolish people have astrange kind of confidence which comes only with ignorance.”)Response.ClearResponse.write(“5. Do your best!”)Response.EndResponse.write(“6. Being ignorant is not so much a shame as being unwilling to learn to do things theright way.”) %>

ii. What will be the output if you will interchange the position of 1st flush and clear.1. II cycle test paper2. ASP5. Do your best!

b) Read the following code carefully<%Response.write( “ welcome”)Response.write(“<br> welcome back”)Server.execute (“city.asp”)Server.transfer(“country.asp”)Response.write(“<br>we all welcome you again”) %>i. What will be the output of the following code if city.asp contains “to the Multimedia Lab” and

country.asp contains “Welcome to Research & Development unit”.welcomewelcome back to the Multimedia LabWelcome to Research & Development unit

ii. What will be the output if you will interchange the position of execute and transfer.welcomewelcome back Welcome to Research & Development unit

Page 20: vinodsrivastava.wordpress · vinodsrivastava.wordpress.com Sample Paper -2 for Exam 2016 Based on VBSCRIPT & ASP Q4,Q5,Q6 (Total Marks Covered : 30) VBSCRIPT 1. Name the tag and attribute

2016-Sample Paper-2

MMWT-SAMPLE PAPERS@ VKS-Learning Hub Page 20

26. Complete the code which shows the no of visitor<% Set pageCount = Server.CreateObject("MSWC..PageCounter") %><% pageCount.Pagehit() %>You are visitor number <% =pageCount.Hits() %> to this Web site.

27. Observe the program segment given below carefully and fill the blanks using methods of theRecordSet object for performing the required task.

<%DIM objConn, strConn, objRSSET objConn = Server.CreateObject (“ADODB.Connection”)strConn = “DSN=exam”objConn. Open strConnSET objRS = Server.CreateObject (“ADODB.Recordset”)objRS.Open “ Select * from Table1”, objConn, 2, 2objRS.MoveLast ‘Move the cursor to the end of fileobjRS.AddNew ‘Line 1 to Add a new blank recordobjRS(“AdmNo”) = Request.Form(“AdmNo”)objRS (“Name”) = Request.Form(“Name”)objRS.Update ‘Line 2 to save the record in the databaseobjRS.CloseobjConn.CloseSET objRS = NothingSET objConn = Nothing%>

27. Write a program to read a text file named abc.txt and print the contents of the file on the screenreplacing all spaces in the file by # symbol.

<%Set objFSO = CreateObject("Scripting.FileSystemObject")Set objFile = objFSO.OpenTextFile("abc.txt")strText = objFile.ReadAllstrNewText = Replace(strText, "", "# ")response.write(strNewText)%>

28. Write a program to read a text file named upper.txt and display the contents of the fileafter converting all the alphabets to upper case alphabets.

<% Set FS = Server.CreateObject("Scripting.FileSystemObject")Set RS = FS.OpenTextFile(Server.MapPath("TextFiles") & "\TextFile.txt",1)While not rs.AtEndOfStreamDim lineReadlineRead=RS.ReadLineResponse.Write("<br>")

Response.Write UCASE(lineRead)Response.Write("<br>")Wend%>

Page 21: vinodsrivastava.wordpress · vinodsrivastava.wordpress.com Sample Paper -2 for Exam 2016 Based on VBSCRIPT & ASP Q4,Q5,Q6 (Total Marks Covered : 30) VBSCRIPT 1. Name the tag and attribute

2016-Sample Paper-2

MMWT-SAMPLE PAPERS@ VKS-Learning Hub Page 21

40. Complete the Code based on text file

i) Code to count the no of line<% Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

Set objFile = objFSO.OpenTextFile("c:\Mydir\myfile.txt")strText = objFile.__________objFile.closeSet objFile=nothingSet objFSO=nothingNLines=split(strText,vbcrlf)Nlines1=objFile.______________response.write(NLines) or response.write(NLines1) %>

ii) Code to count the no of word<% Set objFSO = CreateObject("Scripting.FileSystemObject")Set objFile = = objFSO.OpenTextFile("c:\Mydir\myfile.txt")strText = objFile.ReadallarrWords = Split(strText, " ")Response.Write(“Number of Words=” & Ubound(ArrWords) + 1)%>

iii) To Display a line beginning with “A” or “T” in a file<% Set objFSO = CreateObject("Scripting.FileSystemObject")Set objFile = = objFSO.OpenTextFile("c:\Mydir\myfile.txt")Do While objFile.AtEndOFStream<>truemyLine = objFile.ReadLine

n=RIGHT(myLine,1)If n== “A” or n==”T” thenResponse.Write(myFile.myLine)End IfLoop%>

IV) To count no of Uppercase,Lowercase and No lines in a file

Page 22: vinodsrivastava.wordpress · vinodsrivastava.wordpress.com Sample Paper -2 for Exam 2016 Based on VBSCRIPT & ASP Q4,Q5,Q6 (Total Marks Covered : 30) VBSCRIPT 1. Name the tag and attribute

2016-Sample Paper-2

MMWT-SAMPLE PAPERS@ VKS-Learning Hub Page 22

V) To Display Alternative Line content in Uppercase in bold<%Set FileObj=Server.CreateObject("Scripting.FileSystemObject")Set newsfile= FileObj.OpenTextFIle("C:\inetpub\wwwroot\abc.txt")Do WHILE newsfile.AtEndOfStream<>TrueResponse.Write(newsfile.Readline)Response.Write("<br>")Response.Write("<B>" & UCase(newsfile.Readline) & "</B>")Response.Write("<br>")LOOP%>

VI) To Display the Content of File and Find the no of Vowels in a file abc.txt<%Set FileObj=Server.CreateObject("Scripting.FileSystemObject")Set newsfile= FileObj.OpenTextFIle("abc.txt")cv=0cl=0Do WHILE newsfile.AtEndOfStream<>Truech=newsfile.Read(1)Response.Write(ch)ch1=Ucase(ch)if ch1="A" OR ch1="E" OR ch1="I" OR ch1="O" OR ch1="U" thencv=cv+1end ifLOOPResponse.Write("<br><br>" & " No of Vowels in File =" & cv)%>

VII) To Find the no of Lines and Words in a file abc.txt"

<%Set FileObj=Server.CreateObject("Scripting.FileSystemObject")Set newsfile= FileObj.OpenTextFIle("C:\inetpub\wwwroot\abc.txt")cv=0cl=0Do WHILE newsfile.AtEndOfStream<>Truech=newsfile.Read(1)if ch=Chr(32) thencv=cv+1elseif ch=Chr(13) thencl=cl+1end ifloopResponse.Write(" No of Space in File =" & cv & "<br>")Response.Write(" No of Words in File =" & cv+1 & "<br>")Response.Write(" No of Lines in File =" & cl & "<br>")

%>

Page 23: vinodsrivastava.wordpress · vinodsrivastava.wordpress.com Sample Paper -2 for Exam 2016 Based on VBSCRIPT & ASP Q4,Q5,Q6 (Total Marks Covered : 30) VBSCRIPT 1. Name the tag and attribute

2016-Sample Paper-2

MMWT-SAMPLE PAPERS@ VKS-Learning Hub Page 23

VIII) To Find the no of Uppercase/Lowercase Letters/Digits/Space/Lines and Words in a fileabc.txt"

<%Set FileObj=Server.CreateObject("Scripting.FileSystemObject")Set newsfile= FileObj.OpenTextFIle("abc.txt")UP=0 ' uppercase letterLO=0 ' lowercase letterDI=0 ' Digitsp=0 ' Spacecl=0 ' linesDo WHILE newsfile.AtEndOfStream<>Truech=newsfile.Read(1)if ch>="A" and ch<="Z" thenUP=UP+1elseif ch>="a" and ch<="z" thenLO=LO+1elseif ch>="0" and ch<="9" thenDI=DI+1elseif ch=Chr(13) thencl=cl+1elseif ch=Chr(32) thensp=sp+1end ifloopResponse.Write(" No of Uppercase letter= " & UP & "<br>")Response.Write(" No of Lowercase letter= " & LO & "<br>")Response.Write(" No of Digit= " & DI & "<br>")Response.Write(" No of Space = " & sp & "<br>")Response.Write(" No of Words = " & sp+1 & "<br>")Response.Write(" No of Lines = " & cl & "<br>")

%>

29. Create a webpage which shows no. of visitors visiting the webpage using page counter component ofASP.

<HTML><BODY><%Set MyPageCounter=Server.CreateObject("MSWC.PageCounter")MyPageCounter.PageHit()num = MyPageCounter.Hits()%><CENTER><H1>This page has been visited<FONT FACE="Regular" SIZE=6 COLOR="blue"><%=num %></FONT>times.</H1></CENTER></BODY></HTML>

Page 24: vinodsrivastava.wordpress · vinodsrivastava.wordpress.com Sample Paper -2 for Exam 2016 Based on VBSCRIPT & ASP Q4,Q5,Q6 (Total Marks Covered : 30) VBSCRIPT 1. Name the tag and attribute

2016-Sample Paper-2

MMWT-SAMPLE PAPERS@ VKS-Learning Hub Page 24

30. Create a webpage which show at least 3 advertisements using ad rotator component of ASP<% set adrotator=server.createobject("MSWC.AdRotator")

adrotator.GetAdvertisement("Ads.txt") %>Ads.txtREDIRECT banners.aspWIDTH 468HEIGHT 60BORDER 0*image1.gifhttp://www.domain1.com/Visit domain1.com30image2.gifhttp://www.domain2.com/Visit domain2.com70

31. Create a webpage which show at least 3 tips of the day on top of the webpage using contentrotator component of ASP.

<% SetCRot=Server.CreateObject("MSWC.AdRotator")Response.Write(CRot.ChooseContent("data.txt")) %>

Scheduler File forContentRotator%% #1<font color=”Red”><B>This is a great day!!</B></Font>%% #4<h1>Smile</h1><imgsrc="smiley.gif">%% #3<a href="http://www.vinodsrivastave.com">Best MMWT Tutorial Site</a>

32. Write the ASP code that will read the values from a table using DSN and displays them<% Dim Connection ,Recordset ,SQLSQL = "SELECT * FROM BOOK_MASTER"Set Connection = Server.CreateObject("ADODB.Connection")Set Recordset = Server.CreateObject("ADODB.Recordset")Connection.Open "DSN=dsn_name"Recordset.Open SQL,ConnectionDo While NOT Recordset.EOFResponse.write Recordset("ISBN_NO")Response.write Recordset("AUTHOR")Response.write Recordset("PRICE")Response.write "<br>"Recordset.MoveNextLoopEnd IfRecordset.CloseSet Recordset=nothingConnection.CloseSet Connection=nothing%>

Page 25: vinodsrivastava.wordpress · vinodsrivastava.wordpress.com Sample Paper -2 for Exam 2016 Based on VBSCRIPT & ASP Q4,Q5,Q6 (Total Marks Covered : 30) VBSCRIPT 1. Name the tag and attribute

2016-Sample Paper-2

MMWT-SAMPLE PAPERS@ VKS-Learning Hub Page 25

33.A software company CITRIX wishes to design an ASP coded web page with thefollowing specifications:

the company wish to display current time and the name of the company on the opening page asdisplayed.

To display a greeting message “ GOOD MORNING “ if the user accesses the website between 5 and12 A.M and “GOOD EVENING “ otherwise.

<html><body><h1><center>CITRIX – AMERICAN EXPRESS</center></h1>The current date and time is: <%response.write(now())%>.<br><%If hour(time())>5 hour(time())<12 Thenresponse.write(“GOOD MORNING”)ElseResponse.write(“GOOD EVENING”)End If %></body>

34.Study the codes given below and answer the questions that follow:Exam.txt

Exam.asp

i. Identify the errors in exam.asp and rewrite the corrected code.Line 2 Should be Set Fs. Server.CreateObject(“MSWC.FileSystemObject”)Line 4 it should be Do Instead of DLine 7 it should be Loop instead of Next

ii. What is the use of the AtEndOfStream method?It checks whether end of text file is reached or not

iii. Give the output of the exam.asp file. Total number of lines=6iv. What will be the output if the f.readline is replaced by f.readall? Total number of lines=1