|
|||
|
|
Functions and Subroutines in ASP
Functions and Subroutines in ASPIf you read our Tutorial on Include Files (SSI) then you learned how to encapsulate ASP code within include files and the benefits it brings us. Function getBalloon(strColour) Dim Tempstr strColour = lcase(strColour) 'This converts the value lowercase. Select Case strColour Case "red" Tempstr = "Here is your red balloon" Case "yellow" Tempstr = "Here is your yellow balloon" Case "green" Tempstr = "Here is your green balloon" Case "blue" Tempstr = "Here is your blue balloon" Case Else Tempstr = "Sorry, we have sold out of that Colour" End Select getBalloon = Tempstr End Function %> A Function is passed some information. The information we pass a Function, is known as an 'argument'. The information we get back from a Function is known as the 'return value'. Whilst a Function can have many arguments, it can only have one return value. Function calcTax(amount, taxrate) Dim Tempvar Tempvar = amount * (taxrate / 100) CalcTax = Round(Tempvar, 2) 'round the result to 2 decimal places End Function %> Again, another basic example. We should notice this time that the Function accepts two arguments. shoppingbill=goodsTotal + calcTax(goodsTotal,17.5) Response.Write "Your shopping came to £" & goodsTotal Response.Write " VAT amount = £" & calcTax(goodsTotal) Response.Write "Total Amount Due = £" & shoppingbill %> Above you see the example function in action... easy huh! Sub Bday(strName, intAge) Response.Write "Happy Birthday " & Name Response.Write ", You are " & intAge & " years old today" End Sub 'now, call the sub bDay "Joe",26 %> The above Sub, demonstrates my point. We put something in, it performs an action (in this case writing to the screen), but nothing is returned to us in the code. One thing that REALLY IS important when using a sub, is that we do not put brackets around the arguments... Because we do not have a return value we do not need brackets and in this case, if we try we will get an error. Rob Collyer, experienced with 20 years programming knowledge and site administrator of www.webforumz.com - Copyright 2003-2004
MORE RESOURCES: Yahoo! News Search Results for website design Yahoo! News Search Results for website design • Concrete-Countertops.org: New Website Explores Concrete Countertop Design Opt... New website, Concrete-Countertops.org offers consumers detailed information on choosing concrete countertops over other leading countertop materials. Built to guide consumers looking for alternative countertop materials, the site covers design ideas, how concrete countertops are made, how they perform and their eco benefits. (PRWeb Nov 21, 2008) Read the full story at ... • Concrete-Countertops.org: New Website Explores Concrete Countertop Design Opt... New website, Concrete-Countertops.org offers consumers detailed information on choosing concrete countertops over other leading countertop materials. Built to guide consumers looking for alternative countertop materials, the site covers design ideas, how concrete countertops are made, how they perform and their eco benefits. • VKI Studios Takes First Prize in Google's Website Optimizer "Design a Feature... In a contest sponsored and judged by Google, entrants were invited to design the best new feature for Google Website Optimizer?. On November 11, 2008, it was announced that VKI Studios had won first prize with its suggestion of an "Integrated Experiment Duration Calculator". • Eye-Catching Cash Loans - Cash Doctors Launch Fresh Website Design (PRWeb via... Australia's leading online payday loan company, Cash Doctors, implement new and improved website design. • Pampered Passions Fine Lingerie Launches New Website Design & Additional Feat... PamperedPassions.com, a leading retailer of women's lingerie and romantic gifts -- have announced the release of a new website design, more user-friendly features and free shipping on all USA orders. |
RELATED ARTICLES
Top 5 Reasons to Track Your Website Traffic #5 User Satisfaction: Learn what your visitors and site users do and do not like about your site. Using a good reporting service allows you to monitor your pages individually to see what pages are clicked on first, the most popular pages, duration of any given visitor's time viewing a page (visit duration), and what pages send your visitors off your site (exit pages). PHP Redirect A PHP Redirect automatically transfers a web user from one URL to another. For example, typing foo. Improve Conversion Rates - Load Times Your site is getting traffic, but conversion rates are horrible. Everything seems to be working, so what's wrong? Your site may simply be to slow. Content Management - The New Standard in Web Design The evolution of web development parallels the model of technology spending by companies today. The style and method has transformed along with the business spending trend. Does Your Business Really Need A Website? Website, website, website, everyone says you need one. But do you really? It all depends. Web Development Processes and Technical Environments The process of Web application development is critical to the success of web-based projects. The proper processes can not be enforced unless technical environments are properly setup. Why Should Your Business Go O.N.L.I.N.E. Optimize your time. How much time each day must you devote to paperwork, scheduling and accounting? You strive to meet the needs of your clients, but when chained to the obligations of business management, it's just as important to make sure the doors stay open as it is to satisfy customers. 5 Essential Traits Of A Home Business Website So you've decided to start an online work at home business and are just beginning to build your website. You probably have a million different ideas for what you want the site to look like. Web Coach Tip: What You Should Know About DIY Web Sites Recently, a friend asked "What's the deal with those DIY companies that advertise "How to get a website with everything your business needs for under $20 bucks a month?". "How can they do that?" she said. You Need To Treat Your Website Like An Employee - Heres 5 Ways To Do It People often come to me in a state of crisis and say their website isn't working. Usually they're in a cold sweat:"Mike, give me some practical things I can do to get more sales from my website!"You want practical advice? Stop treating your website like an object in your business and start treating it like an employee. Web Measurement: What You Don't Know Would Make A Great Book "What's in it for me?" you ask. "Why should I measure how people use my website? How does it help and what does it all mean?" The purpose of this article is to try to give you some insight into effective web measurement and to talk about the most important page of any website, the landing or home page. Create Huge Income From Your Web Site - 10 Easy Ways The cost of setting up a web site is dirt cheap nowadays. You can register a domain for less than $2. 7 Profit Producing Reasons Why Every Successful Service Professional Needs A Web Presence Your business website is a critical aspect of being able to start and continue conversations with potential clients. It's the ultimate self-service window for potential and current clients who come to you interested in your services and/or products. Content Management More and more businesses are recognizing the importance of content management when it comes to their websites. Website content is more important than ever before, and as the Internet matures and changes, it is likely be become even more important. Lead Generation How to -- 10 Tips On Generating More Internet Sales Leads Many millions of dollars are being wasted on promoting and sending traffic to ineffective lead generation websites. Here are my top 10 tips to make your site generate more leads for you and your company. The Power Is In The Pipes: How To Get Maximum Leverage From Your Website What is the most important part of your online business?Many people would say: "my website". And that'sunderstandable - it's the most visible part of an internetbusiness. For Newer Sites, Web Marketing Depends On Titles & Links! We all start out the same. Some have budgets, some don't. Website Imperatives and Solutions When you take a look at the most visited sites on the internet, what hits you in the face? Change, growth, new content. In a sense, a search engine is the perfect web site. Where on Earth is Your Websitee? You've just finished congratulating your marketing team. After six months of concentrated effort you can now actually find your own company web site within the search engines. The Evolution Of Search There have been many significant changes to the face of search over the last several years with engines becoming more intelligent than ever before. Today's users expect mainly fast, easy, relevant and satisfactory search results. |
| Food PeoplesChoice | Web Starter | PhotoLog | Workstations | Web Design | Photo Blog | Articles Searches | Daily Blog MP3 | |
|
|