0% found this document useful (0 votes)
84 views

Program 5 Write A Program To Compute The Arithmetic and Geometric Mean Using Vbscript

The document describes 9 programs written in VBScript to demonstrate different features of ASP: 1) Computing arithmetic and geometric means 2) Creating a simple form using the POST method 3) Creating and retrieving session objects across pages 4) Implementing cookies to track number of page visits 5) Checking browser capabilities using the BrowserType object

Uploaded by

kunalgourav02
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
84 views

Program 5 Write A Program To Compute The Arithmetic and Geometric Mean Using Vbscript

The document describes 9 programs written in VBScript to demonstrate different features of ASP: 1) Computing arithmetic and geometric means 2) Creating a simple form using the POST method 3) Creating and retrieving session objects across pages 4) Implementing cookies to track number of page visits 5) Checking browser capabilities using the BrowserType object

Uploaded by

kunalgourav02
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 14

Program 5 Write a Program to compute the Arithmetic and Geometric mean using vbscript.

<%@ Language =VBScript %> <% Option Explicit Dim iTerm1,iTerm2,SngArithmetic,SngGeometric %> <HTML> <BODY> <% iTerm1=5 iTerm2=16 Response.Write("we are computing the average of ") Response.Write(iTerm1) Response.Write(" and ") Response.Write(iTerm2) %> <BR> <% SngArithmetic=iTerm1+iTerm2 SngArithmetic=SngArithmetic/2 SngGeometric=(iTerm1*iTerm2)^0.5 Response.Write("Their arithmetic Mean is")
1709103 13

Response.Write(SngArithmetic) Response.Write(" and their geometric mean is ") Response.Write(SngGeometric) %> </BODY> </HTML>

Output:

1709103

14

Program 6 Write a Program to create a simple form using POST method. a) Simpleform.asp

<%@language=vbscript%> <%option Explicit%> <html> <body> <form method=post action="collectinfo.asp"> TextBox1: <input type=text name=textbox1> <br> TextBox2: <input type=text name=textbox2> <p>
1709103 15

<input type=submit> </form> </body> </html>

b)

Collect info.asp

<%@language=vbscript%> <%option Explicit%>

<% Dim text1,text2 text1=Request.Form("textbox1") text2=Request.Form("textbox2") Response.Write "TextBox1=" & text1 %> <br> <% Response.Write "TextBox2=" & text2 %>

1709103

16

Outputs: a)

b)

1709103

17

Program 7 Write a Program to create a session objects and retrive in other file. a) Sessionobj.asp

<%@language=vbscript%> <%option Explicit%> <% Dim sentence(4) sentence(0)="This " sentence(1)="is " sentence(2)="SSP " sentence(3)="Programming " sentence(4)="Lab."
1709103 18

Dim iloop For iloop=LBound(sentence) to UBound(sentence) Response.Write sentence(iloop) Next Session("sent")=sentence %>

b)

Session.asp

<%@language=vbscript%> <%option Explicit%> <% Dim iloop If IsArray(Session("sent")) then For iloop=LBound(Session("sent")) to UBound(Session("sent")) Response.Write Session("sent")(iloop) Next Else Response.Write("No sentence to process") End If %>
1709103 19

Outputs: a)

b)

1709103

20

c)

1709103

21

Program 8 Write a program in ASP that shows the implementation of Cookies .


<% language=vbscript %> <% dim nvisits response.cookies("NVisits").Expires=date+365 numvisits=request.cookies("NVisits") if nvisits="" then response.cookies("NVisits")=1 response.write("Welcome! This is the first time you are visiting this Web page.") else response.cookies("NVisits")=nvisits+1 response.write("You have visited this ") response.write("Web page " & nvisits)
1709103 22

if nvisits=1 then response.write " time Before!" else response.write " times After!" end if end if %> <html> <body> </body> </html>

Output:

1709103

23

Program No 8 Write a program is ASP to check the capabilities of the browser using browser capability component.
<% language = vbscript %> <html> <body> <% Set MyBrow=Server.CreateObject("MSWC.BrowserType") %> <table border="1" width="65%"> <tr> <td width="52%">Client OS</td> <td width="48%"><%=MyBrow.platform%></td> </tr> <tr> <td >Web Browser</td> <td ><%=MyBrow.browser%></td> </tr> <tr> <td>Browser version</td>
1709103 24

<td><%=MyBrow.version%></td> </tr> <tr> <td>Frame support?</td> <td><%=MyBrow.frames%></td> </tr> <tr> <td>Table support?</td> <td><%=MyBrow.tables%></td> </tr> <tr> <td>Sound support?</td> <td><%=MyBrow.backgroundsounds%></td> </tr> <tr> <td>Cookies support?</td> <td><%=MyBrow.cookies%></td> </tr> <tr> <td>VBScript support?</td> <td><%=MyBrow.vbscript%></td> </tr> <tr> <td>JavaScript support?</td> <td><%=MyBrow.javascript%></td> </tr> </table> </body> </html>

1709103

25

Output:

1709103

26

You might also like