| <% Sub GetInfo() dim name,telephone,fee name="Mr. John Doe" telephone="555-5555" fee=20 Response.write("Name: "& name &"<br>") Response.write("Telephone: "& telephone &"<br>") Response.write("Fee: "& fee &"<br>") End Sub GetInfo() %> | This example simply declares, populates, & writes three variables in the asp sub procedure, ‘GetInfo‘. This sub is executed right after the end sub. Here is the execution result: Name: Mr. John Doe Telephone: 555-5555 Fee: 20 |
| <% Sub circle(r) dim pi,area,diameter,circum pi=3.14 area=pi*r^2 diameter=2*r circum=2*pi*r Response.write("The Circle with a radius of: "&r&" has the area of: "&area) Response.write(", the diameter of: "&diameter&" and a circumference of: "&circum) End Sub %> | Here is the execution result: The Circle with a radius of: 2 has the area of: 12.56, the diameter of: 4 and a circumference of: 12.56 |
ASP Function ProceduresThis is a none-parameterized asp function procedure: <% function userName() userName="MaryLou" end function %> This function procedure remembers a username. You can use this function any number of times in your program, and you can change it once to maintain it- use ‘userName()‘ to call this function. For example: response.write("The username is: "&userName()) This is a parameterized asp function procedure: <% Function total(price) dim tax tax=price*.09 total=price+tax end Function %> The price value is provided when calling the function- Example: response.write("The total price is: " & total(50)) This is an asp function procedure that accepts an argument:
| ||
聯(lián)系客服