- Functions and Subroutines in ASP

 
    Home |  Site Map |  Useful Links |  Downloads |  Contact Us |  Online Store
Search
Powered by Google
 
 
 
 
 
 
 
1 Simple Solution to All Internet Marketers about Their Website Design Needs
10 Simple Steps: It's Magic If You can E-Mail You can Update Your Web Page Dynamically
10 Things You Can Do To Sell (A Lot Of) Ads On Your Website
10 Things You Should Be Monitoring On Your Website
10 Tips For A Successful Website
10 Tips For Running A Profitable Web Site
12 Essential Tips to a Professional Business Website
12 Tips To Great Websites
13 Ways to Destroy Your Website
17 Tips to Plan a Website
2 Key Ways to Make Your Site a Success
3 Essential Tools Every Website Designer and Marketer Needs
3 Marketing Mistakes Web Site Designers Make When Selling Their Services
3 Reasons Why You Need URL Rewriting Module To Enchance Your Web
3 Rules of Website Designing and Layout
3 Ways To Increase Your Website's Conversion rate
35% Revenue Increase- from Your Website!
4 Marketing Tips for Resourceful Webmasters!
4 Must-Have Tools For Turnkey Web Site Developers
4 Rock Solid Reasons For Building Your Own Website
4 Steps to Selling More With Your Web Site
4 Tips To Build A Content Site With More Repeat Visitors
5 Essential Traits Of A Home Business Website
5 Sure Fire Ways To Send Visitors Away For Good
5 Tips For A Better Website
5 Tips To Supercharge Your Website Sales Copy
5 Ways to Build a Website
50 Ways To Use Your Website
6 Steps To Your Own Website
7 Golden Rules For Building Mini Sites
7 Killer Ways To Increase Your Online Sales
7 Profit Producing Reasons Why Every Successful Service Professional Needs A Web Presence
7 Questions to Understand Your Customer Better
7 Reasons Why Your Small Business Needs A Web Site
7 Reasons YOU Need a Website
7 Tips to Make Your Order Page Work Harder
7 Ways to Gain a Professional Online Reputation
8 Guidelines for Usability Testing
8-Reasons All Non-Profits Need A Web Site
9 Keys to an Effective Website
9 Simple Steps to Create a Background Tiled Image Branded with Your Name
A Beginners Guide to Server Side Includes
A Closer Look at Using a Template Site - Is It Professional Choice?
A Guide To Worldwide Internet Access
A Network Of Web Sites Is Not Enough!
A New Meaning of Denver Web Development
A Web Site for Your Small Business: How to Set Up a Website
A Website Is Not Enough
Abandonment - Why Visitors Don't Turn Into Customers
Achieving Differentiation With Your Website
Adding Word Rich Content to Your Website
Advanced Hotlink Protection
Advice On How To Obtain An Internet Presence On The Cheap
Allocating Your Web Site's Budget Properly
Analyzing Traffic - Visitors V. Hits
Are Web Graphics Stealing Your Money?
Are You Being Scammed By Your Web Design Company?
Are You Being Scammed
Are You Losing Sales Because of These 4 Simple Website Mistakes?
Are You Overlooking the Benefits of Using Sub-Domains within Your Web-hosting account?
Art, Artists and the Web: Part 4-What to Do After a Website is Designed
Art, Artists and the Web: Part 3-What to Put on an Artist's Website
Art, Artists, and the Web:Part: 2-First Steps in Building an Artist's Website
Autoresponders Make You Look Like A Pro
Avoiding Web Site Mistakes - Advice for Three of the Biggies
Be Creative Before You Purchase Or Create A Website
Beautiful Web Sites Seldom Make More Sales
Benefits Of An Accessible Website: Part 1 - Increase In Reach
Benefits Of An Accessible Website: Part 2 - The Business Case
Benefits Of Making Your Website Accessible To Disabled Users - Part 2: The Business Case
Better Web Site ROI: Efficient Online Business with SEO, PPC, Split Testing, and Forums
Beware the Software Siren
Beyond Web Usability: Web Credibility
Bring Your Visitors Back Clamoring for More! Maintain and Improve Your Web Site Weekly - Part 1
Build It and They Will Come
Build Profitable Business Online
Build a Strong Foundation for Creating Your First Online Identity - Notes for Beginners
Build a Web Site that Works...Even for a Safari Hobby!
Build or Buy a CMS?
Building Websites with Directory Generator
Building Your Business Through Content
Building a Great Intranet Taxonomy
Building a Web Site Requires the Right Software to Eliminate Headaches and Keep Money in Your Pocket
Building a Web Store on Shoestring Budget in less than Four Hours
Building an Easier Site with PHP Modules
Building eCommerce Websites that Work - Part 2
Building eCommerce Websites that Work - Part 3
Business Website Building Do's and Don'ts
But My Business Doesn't Need A Website!
CMS - How to Choose the Right Content Editor for Your Site?
CPanel Fantastico - Features and Benefits
CSS - Maximum Benefits
Chat Room Design with PHP and MySQL
Conceptualize, Build and Publish a Web site
Content Management - The New Standard in Web Design
Content Management System: True Power and Capabilities
Content Management
Content: The Key To Increased Website Traffic
Cost Effective and Powerful Dynamic Websites w. Fantastico Web Hosting
Create Huge Income From Your Web Site - 10 Easy Ways
Create Your Own Download Linkls
Create a Traffic Stampede with More Web Content
Create your own web site
Creating Compelling Content , Write It and They Will Come
Creating Dynamic Website Content with PHP - MySQL
Creating Websites that Cater to Exam Preparations
Creating a 'Sticky' Web Site
Creating a Landing Page Campaign: 7 Things to Avoid
Creating a Search Engine Friendly Web Site
Creating a Sticky Web Site
Creating a Website Based on Adsense Revenue Model
Credibility - 10 Ways to Build it on Your Website
Database Driven Web Site - Do You Need It?
Design Can Get You to the Door, but Content is the Key
Design a Search Engine for Your Own Site with PHP
Develop a Solid Website Presence
Developing A Login System With PHP And MySQL
Developing A Website: 10 Tips For Getting Started
Developing State-enabled Applications With PHP
Direct Sales and Your Corporate Website - A Creative Marketing Plan that Works!
Disability Discrimination Act (DDA) & Web Accessibility
Do Authors Need a Website?
Do Dancers Need A Website?
Do This One Thing to Create a Powerful Product-Selling Web Site
Do You And Your Website Have Credibility?
Do You Need a Web Database?
Do You Really Need A Website To Succeed
Does My Company Need A Website?
Does Your Business Really Need A Website?
Dot Gov... Dot Dull?
Dreamweaver 8 Preview
Duplication vs. Individualism
Earn On Offshore Web Design and Development
Earning From Your Website
Easy Steps To Website Development and Promotion
Ebooks for Webmasters
Ecommerce Solutions for Small Business Owners
Ecommerce Web Sites: If You Build It They Will Come - Or Will They?
Ecommerce for Beginners
Effective Webdesign
Effectively Using Robots Meta Tags
Eight Deadly Web Site Mistakes and How to Avoid Them
Email Addresses in Web Pages
Enhance Your Website With A Yahoo-Style Directory
Entangled in the World Wide Web
Establishing Your Web Presence
Ever Wondered What Challenges Other People With Their Web Site?
FREE Amber Alert Tickers for Your Website
Find the Purpose of Your New / Proposed Website
Finding The Right Log Analyzer
Finding the Best Domain Name, Host and Graphics for Maximum Profit
Five Essential Questions to Answer Before Creating Your First (or second...or third) Website
Five Question-Five Minute Web Makeover Quiz
Five Reasons You Have to Stop Your Web Site
Five Steps to Create Your Software Product with Outsourcing
Flash Deadly Sins (That Can Kill Your Web Business)
Focus on Your Goal and Stay Focused
For Newer Sites, Web Marketing Depends On Titles & Links!
Free Isn't Always Good - 5 Reasons Why You Need Your Own Website
Free Webmaster Tools - 7 Things Every Webmaster Needs in Their Toolbox
Free Websites & Why You Should Avoid Them
Freelance Programming is Easy to Manage
Frequent Business Question: How Do You Start a Web Business?
From Concept to Website
From Search to Sale
****Functions and Subroutines in ASP****
Generating a Randon Number in PHP
Get Your Business on the Web
Get a Website!, Register Your Domain!: To Website or Not to Website?
Get to Know People through Websites
Getting One-way Inbound Links: the 5 Major Strategies
Getting a Web Site Can Be Fast, Easy, and Inexpensive When You Know Your Options
Getting a Website: How to Get a Better Price from Your Website
Give Your Business a Cash Infusion
Growing Your Meetings In CyberSpace
Guide to Internet Business - Design and Content
Guide to Internet Business - Website Setup
Guidelines for Web Page Optimization
HTML Editors - How to Choose the Right One for Building Your Websites
HTML Editors 101 - Smaller Is Better
Have You Got Your Ear To The Ground Or Your Head In The Sand?
Having a Domain Name And Web Site Gives Your Business The Key To The Door
Having a Portfolio on the Internet Can Help you Infiltate the Workforce
Help Visually Impaired Visitors to 'View' Your Website
High Quality Website at Low Cost
How Did You Get Here?
How Disabled Users Access The Internet
How Does Your Website Make Me Feel?
How I can Guarantee you Quality Links
How Improving Your Sites Usability Can Increase Your Buyers by 40% and Boost Each Order By 10%!
How One Word Or Even One Letter Can Boost Conversion Rates By Over 400%!
How Professional and Credible Does Your Website Appear to Your Viewers?
How To Convert More Sales On Your Website
How To Easily Build A Free Website For 7 Days
How To Evaluate Your Web Sites Performance
How To Get Profits From Your '404 Page Not Found' File
How To Get Visitors To Trust Your Web Site
How To Get Your Customers To Trust Your Website
How To Keep Your Website Sticky
How To Make Your Website More Successful? (Part I)
How To Setup Your Site's Article Directory
How To Start Your Own Website
How To Write More Powerful Online Text
How Web Analytics Helped Find A Million Dollar Hole
How Web Templates Are Helping Online Businesses to MultiplyTheir Income
How Worldly is Your World Wide Web?
How Your Own Website Helps Your Small Business Grow
How to Build a Content Site - Fast!
How to Build a Database Driven Web Site
How to Create Sizzling Sales online
How to Create a Professional Web Site in 24 Hours
How to Create a Successful Directory
How to Draw Icons or Images on a Mapserver Generated Map
How to Get Your Website In Front of Thousands of Customers At No Cost To You!
How to Get a Better Web Site ROI
How to Get a Knock Out Website!
How to Get a Website!
How to Handle Web Surfers Who Disabled JavaScript
How to Increase Sales with Automation Improvements
How to Listen on the Web
How to Make Sense of Your Website's Statistics?
How to Make Your Content Management System / Web Portal More Secure Durring Setup
How to Make Your Own Free Website in 8.5 Minutes or Less
How to Make Your Own Website For Free
How to Maximize the Value of Every Visitor to Your Website
How to Measure Your Website's Performance
How to Promote Your Law Firm Website On the Internet for Maximum Profit
I Did It: Six Months to a Successful Website
I Want To Be A Freelancer
If It's Done It's Done for: Make Your Website Part of Your Business before You Build
If You Build It, They Will Come?
Important! How Site Speed Can Affect Your Sales!
Improve Conversion Rates - Effective Content
Improve Conversion Rates - Load Times
Improve Web Sales Figures Forever And Ever Amen!
Improving Usability for Screen Reader Users
In Business? 10 Reasons Why You Need a Website - Now!
In a Town Called Google the Keyword is Real Estate
Increase Hits to Help Increase Your Business
Increase Your Affiliate Earnings with a Smart Webmaster Plan
Increase Your Website Sales Without Increasing Website Traffic
Instant Relevant Web Site Content - No It's Not a Bot
Internet Basics: A Database-Driven Website is Like a Sandwich Machine
Internet Marketing Website Promotion -The 7 Biggest Mistakes I See People Make With Websites!
Introduction to MySQL with PHP
Introductory PHP For Non-Programmers
Is Your Web Site Talking to Your Customer?
Is Your Website Doomed for Failure Before You've Built It?
Is Your Website Image Up to Par?
Is Your Website Innovative? Increase Your Business Over Night!
KISS Your Website!
Launch Your Own Website Today - It's Easier Than You Think!
Lead Generation How to - 10 Tips On Generating More Internet Sales Leads
Learn What 98% of Targeted Visitors Do On Your Website
Learn to Build a Better Online Business Website Using Keywords and Content
Let Marketing Manage Your Website Content
Let Your Customers Redesign Your Website!
Link Trades That Waste Your Time
Linking Out is Good
Links, Links, Links - Do You Really Need Them?
Live Support from Your Website? Can You Do It for Free?
Loading Your Website Quickly
Look For The Obvious And Work On It
Maintaining Your Business Website
Make Your Artist Website Sell!
Make Your Communication Come Alive
Make Your Own Brand!
Make Your Own Website - General Website Design Tips
Make Your Web Site Stand Out
Make Your Web Site User-Friendly!
Make Your Website Something Worth Coming Back to
Make a Habit of Analyzing Other Sites for Form, Function, and Design
Making The Business Case For Web Standards
Making Your Website Shine! Attract and Keep Visitors at Your Site!
Making Your Websites More Compelling
Making the Most of Your Website: Start with the Basics
Market Your Storefront with a Website
Marketing Your Business Online
Maximizing ROI via Web Site Traffic Analysis
Most Websites Don't Work: The Top Five Reasons Websites Fail
My Yahoo Search - Beyond Bookmarks
MySQL Database Handling in PHP
New Year's Resolutions: Is Improving Your Website One of Them?
Newsletter Management Using PHP w/o mySQL for Beginners
Non-Profits: Successful Online Strategies
Nonsense! Why Do I Need a Website?
Now You Have a Web Site - Have You Ever Heard of Accessibility?
Observing the Protocols: HTTP, WWW, URL and HTML
Optimal Website Design
PHP & Account Activation
PHP Redirect
PIM Team Case Study: Creating Text Effects With PHP and GD
Pick Up Your Own Domain Name
Planning A Usable Website: A Three-step Guide
Planning Your Website for Success
Prepackaged Shopping Cart Software: Upgrade Your Site
Preventing Repeat Form Submission Using PHP Sessions
Print-this-page Function - a Bad Idea and Its Solution
Product Promoting: Getting The Response
Profitable Websites for Exclusive Industries
Recycling Article Content on Your Website
Remember This When Building A New Site - Beginner's Guide
Research of Art Online Submission Format Modeled After Article Websites
Revealing the Firefox Secret Used by Top Web Developers and Power-Browsers
Running An Effective Website
Sales Leads - Three Things Every Website Should Do
Save 10 Hours a Week by Setting Up Your Own Faux Finish Website
Search Engines and Customers Want Focused Web Site Content
Selecting a Quality Domain Name
Selecting a Web Content Management Product
Selling Your Site: Outsource or Homemade?
Server Side Includes (SSI) with ASP
Server Stats - Analyzing Traffic To Your Site
Set Up Your Website in Minutes - For Free
Setting Up A Business Web Site That Works
Setting Up A CGI Script On Your Web Site
Setting Up Your First Website
Setup Website: Setup Your Business for Success
Seven Daft Things Not To Do To Your Website
Should You Design Your Own Website?
Simple & Free Website Calendar
Six Basic Reasons Why Visitors Stay On Your Web Site
Small Business Internet Presence - Getting Started
So You Want To Have A Website
Spyware: The New Cancer
Step by Step Making Site on the Web
Steps to Solving the Spyware Threat
Sticking To Your Plan
Stop Losing Precious Web Site Traffic to the Dreaded World Wide Web Black Hole
Streamline your Business Website with a Content Management System
Study Your Site's Performance Via Hit Tracking
Successful Commercial Sites
Successful Web Development: 10 Key Elements
Successful Web Site Presence, Global Marketing Strategy, Online Website Presence Resources
Take Action: Create a Website Strategy that Generates Revenue
Tell me what your website does!
Templates: Building Your Own Website? Don't Even Bother
Ten Major Tips to Develop a Multilingual Web Site to Work
Ten Quick Tests To Check Your Website For Accessibility
Ten Ways NOT to Set Up a Website-based Service Business
The 2 Most Common Web Site Mistakes
The 5 Biggest Mistakes Almost All Web Designers Make
The 7 Key Elements Webmasters Don't Know About Creating an Outrageous Profitable Mini-site
The Basics of Starting Your Own Website
The Birth of a Professional Web Site
The Cost Of A Web Site
The Disability Discrimination Act (DDA) & Web Accessibility
The Do's and Don'ts of Launching a Small Business Website
The Evolution Of Search
The Future Of Web Design Is Content Management!
The Importance of Content - Adding a Weblog To Your Site
The Importance of Website Stats to You
The Internet Offers a Tremendous Marketplace
The Internet Road Map
The Most Important Aspect of Writing Web Copy
The Number 1 Reason Most Websites Fail
The Number One Reason Most Websites Fail
The Power Is In The Pipes: How To Get Maximum Leverage From Your Website
The Power Of CPanel
The Problem with Automated Accessibility Testing Tools
The Problem with Paypal On Your Web Page
The REAL Cost of Building and Maintaining a Commercial Website
The Road to Better Results
The Secret Benefit Of Accessibility: Part 1 - Increased Usability
The Secret Benefit Of Accessibility: Part 2 - A Higher Search Engine Ranking
The Success of Your Web Site with King Content
The Top Ten Benefits of Having a Web Site
The Topic Of Your Website
The Two Most Common Mistakes That Scare Away Web Visitors
The Web: Your Window of Opportunity
The Wonders of Content Management Systems
Things to Consider Before Starting a Website
Thinking Of Taking Money Online? What's Best For Merchants? PayPal, WorldPay or Something Else?
Three Things Every Website Should Do
Three Way Linking - Webmaster Strategy
Tim Berners-Lee: A Tribute
Tips for Building a Great Business Website
Tips to Protect Your Downloads or Products
Top 10 Webmaster Challenges
Top 5 Reasons to Track Your Website Traffic
Top 5 Webmaster Tools You Can Pick Up For Pennies
Top 7 PayPal Credit Card Processing Advantages
Top 7 Reasons Why Your Business Needs a Website
Top 7 Tips for Building an Antique Car Website
Topics to Add When Creating an Alternate and Modern Medicine Web Directory
Track Your Visitors, Using PHP
Traffic for Webmasters
Trinkets, Lockets And Empty Pockets
Trust Us! Sending Credible Messages
UK Online Shopping with an Edge, for Buyers and Sellers Alike
Unlocking the Power of Your Website!
Up The Sandbox!
Updating Your Web Site Efficiently
Updating Your Website and Adding Fresh Content
Usability and ROI: The Great Debate
User Interface Design: Key to Achieve Best Web Development
Using Free Content to Keep Visitors Interested!
Using Mini Websites - Powerful Way to Direct Marketing
Using Other People's Articles To Boost Your Web Site Profits
Using Psychology Easily on Your Website to Make More Sales!
Visitors Leave After Seeing My Home Page - Aye, Carumba!
WYSIWYG Versus Coding: HTML With A Purpose
Warning: The Truth About Having a Web Site!
Web Accessibility Myths
Web Accessibility: The Basics
Web Analytics - Getting it Right
Web Business Overview - Have a Plan
Web Coach Tip: What You Should Know About DIY Web Sites
Web Content Strategy 101
Web Content: How Much Should I Pay?
Web Content: What Makes It Different from Print
Web Design Firm: Professionals or Trouble?
Web Design for the Professional Magician Part I - Selecting the Perfect Domain Name
Web Designer? You Don't Need No 'Stinkin' Web Designer!
Web Development Processes and Technical Environments
Web Development Terminology: How to Know What Your Design Team is Talking About
Web Journeys
Web Measurement: What You Don't Know Would Make A Great Book
Web Site Accessibility - Why Make a Web Site Accessible?
Web Site Accessibility and Web Standards - Get More Visitors and Make More Money
Web Site Analysis - A Study in Damage Control
Web Site Development Process - The Life-cycle Steps
Web Site Optimization: How To Speed Up Your Web Site By Minimizing Your GIF and PNG Image Bit-Depth
Web Site Promotion: How To Advertise Your Website For Profits
Web Sites - Should I Learn or not?
Web Success Secret - Keep Your Visitors Interested
Web accessibility for screen magnifier users
Website Benefits - Why a Website could be Beneficial to Your Organisation
Website Content & Usability
Website Conversion Rate: More Keywords Equals More Sales
Website Development - An Engineering For The Commercial Purpose
Website Development: Become Your Own Expert
Website For The Company Store
Website Globalization
Website Imperatives and Solutions
Website Sales: 10 Reasons Why People Don't Buy From You
Website Strategy!
Website Success is Key
Website Survival Guide
Website Translation and Localization: DIY Guide
Website Value - What's Your Business' Website Worth?
Websites - Why Your Company Needs One and How to Get Started
Websites for Writers - Why You Need One and How to Get Started Today
Websites: You Get What You Pay For!
What Business Owners MUST Know BEFORE They Commit To Having A Web Site
What Does An Ex-Basketball Coach Know About Pulling Web Metrics?
What Hosting Companies Dont Tell You, Could Hurt You-
What ROI You Should Expect From Your Web Site
What Works and What not Works for Your Internet Business
What YOU Should Know Before Getting A Web Site!
What Your Customers Say About YOUR Site! Part 1
What and How to choose the Right Keywords for Mega Traffic
What is Blogger.com?
What is SQL?
What is The Google Toolbar?
What's Your Business Online Attitude?
When is a Website Ready for Launch/Relaunch?
Where on Earth is Your Websitee?
Where's Your Focus, Money or Customer?
Where's Your Web Site?
Who Owns Your Website?
Why A Simple Counter is Never Enough for Your Website
Why Do I Need A Web Site?
Why Do You Need A 'Content Rich' Website?
Why Does Your Business Need a Website?
Why Every Small Business Owner Needs Two Websites
Why Is No-one Buying From My Website?
Why Local Service Companies Should Have a Website
Why Online Presence Is Essential For Small Business Success
Why Should I Bother With Optimised Online Copywriting?
Why Should Your Business Go O.N.L.I.N.E.
Why You Need A Web Site
Why You Need a Website
Why You Really Need Your Own Web Page In-order To Make Online Business!
Why Your Brick-and-Mortar Biz Needs A Website
Why Your Business Needs a Website
Why a CSS Website Layout Will Make You Money
Why a Website is Very Important to Your Business
Why do I Need a Website?
Why is Optimizing Your Site For Speed is Important? Tips on How to Do So!
Why to Have a Website for Your Company
WordPress Made Real Easy!
Writing Effective ALT Text For Images
Wysiwyg?
You Can Prevent the Potential European and Asian Dominance of the Internet Marketing Business
You Can't Just Build A Website And Hope It Works!
You Don't Have to be Amazon.com to Achieve 12% Conversion Rates!
You Don't Know Which One
You May Be Losing Valuable Traffic - And Not Even Know It!
You Need To Treat Your Website Like An Employee - Here's 5 Ways To Do It
You Need a Website!
Your Biggest Mistake When You Create a Website?
Your Content for Nothing and Your Clicks for Free
Your Future Profit Is In The Stars
Your Website Reflects Your Business
Your Website Should Be Selling
Your Website: If You Build It, They Will Come?
 
You are in - Home » Articles » Internet and Businesses Online » Web Development
 

Functions and Subroutines in ASP


Functions and Subroutines in ASP

If 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.

As developers, we should endeavour to make our lives easier wherever possible... no one wants to re-invent the wheel after all.

Functions and Subroutines exist to not only save us time, but to bring power to our ASP.

They are just another way of encapsulating code, but have a lot more functionality than just 'saving some code for later'.

First, let's look at Functions... Imagine a balloon salesman in the street. We've all seen them they require one piece of information when you buy a balloon, the colour.
Let say we asked for a red balloon... The balloon salesman armed with this 'information' then does a pretty basic action... he hands you the balloon. The balloon you received is a direct result of the information you gave the balloon seller.

Functions are just the same... they return to you a value based on the information you provided. Lets look at an example Function: -

<%
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.

Let us look at one more example: -

<%
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.

By now, we have some idea of how to write a Function. How do we use one?
Let me show you now how we can use the calcTax example.

<%
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!

I have tried to make understanding Functions as easy as possible... Understanding a Subroutine (Sub) is now going to be easy for you. Imagine a block of code that performed some instructions based on information you gave it...
Sounds very much like a function, doesn?t it? Well this time, we do not get anything back. A sub does NOT pass back information it just uses the data we give it for some purpose.

I will use only one example of a Sub, and in the same example make use of the sub: -

<%
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.

Well, that just about concludes this article. We should by now be writing efficient code with the use of Functions and Subs. Don?t forget that if you use your functions and subs in multiple pages then you should really store them within include files for reasons of easy maintenance and better performance.

Rob Collyer, experienced with 20 years programming knowledge and site administrator of www.webforumz.com - Copyright 2003-2004

Article Source - Article Monster.com


 

Disclaimer

 ^^Top of Page^^