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

In The News:

Outsource Web Development: Lessons to Keep in Mind  YourStory.comWhen a company decides to take outsource web development services, there are many aspects that it judges the outsourcing company before finalizing the ...
What are the latest web development Trends For businesses In 2019?  YourStory.comIt's impossible to go along with web development trends; because it is subject to change. Rarely, a week passes without any release of a new JS framework, ...
How Link Digital left web development behind to drive data growth  ITworldMaking its mark as a Canberra-based web development company in 2001, Link Digital began moving towards open data services about five years ago, based ...
Why Aren't HTML/CSS/JavaScript Being Taught in Our Schools?  Interesting EngineeringSchools around the world should be teaching children web development tools, such as HTML, CSS and JavaScript, but they aren't. Instead, a number of online ...
5 Benefits of Android Web Development  NewsWatchAmong all of the directions, where a base language for development is Java, app and web development for Android developers are the most undemanding to ...
The Web Development Capabilities You Need For Your Small Business  Customer ThinkResearch has found that less than two-thirds of small businesses have websites. Thankfully, over half of those without websites say they plan to build a site in ...
Top 5 WordPress Development Companies in the World  YourStory.comAre you searching for top WordPress development companies? We are providing you the list of top and best WordPress development companies in the world.
Panic announces all new web development editor coming this year as Coda 2 successor  9to5MacThe developers at Panic today revealed some major changes coming soon to its web development offerings. The company says that later this year, it will release ...
Become a full stack web developer with 46+ hours of training for $29  XDA DevelopersMany developers only focus on one or two languages. By specializing in this way, you rule yourself out of many great opportunities. In contrast, full stack ...
5 Questions to Ask Remote Web Developers  DevOps.comHere are some questions to ask when interviewing remote web developers to understand whether they'd be a good fit for working remotely.
What Are The Emerging Trends In Web Development In 2019?  Promotion WorldUsers expectations are growing and to meet their expectations developers need to design more engaging digital experience. Make sure that website can.
Tech internships in IoT, web development social media; highest stipend Rs 15,000  The Indian ExpressHere is a list of internships in the technology domain, from the latest internet of things (IoT) to social media, Bangalore has many openings. Students with ...
The seven deadly sins of web design  Packt HubFor a great website, web developers meet client demands while at the same time thinking about users. Gary stevens discusses more such in his article.
Daily Deal: The Complete Full Stack Web Development Master Class Bundle  TechdirtThe $19 Complete Full Stack Web Development Master Class Bundle is seven courses covering today's hottest web frameworks and technologies. You'll start ...
Bottrell Media - Web Development  WhaTechBottrell Media provides professional Website Design and Development services in Sydney, Maitland, Newcastle, Gold Coast, Brisbane, and Melbourne. Contact ...
Top Web development tips to get the success of your website - WhaTech  WhaTechWebsites are a crucial part of a business. In today's business world, not having a website for your business will make you lack behind your competitors because ...
10 Web Development Tips to Better Your Website Success  Thrive GlobalThe most common mistake any firm or individual can make when endeavor out on a new website project is to consider that design is everything. I can assure you ...
Tips to improve your web development process - WhaTech  WhaTechJust like Google, Safari or any other search engine, web development services make changes regularly to get the best practices. If you want the best web ...
OMNICOMMANDER Launches Upgraded Website Showcasing Industry Leading Web Development and Marketing Services  PRNewswireMIRAMAR BEACH, Fla., March 11, 2019 /PRNewswire/ -- OMNICOMMANDER, a financial technology firm specializing in website design, social media ...
10 programming languages that are in demand among top hiring companies  Express ComputerCoding continues to be one of the most in-demand skills in the job market. Many professionals are considering getting into the field. Possessing the required ...
Learn how to build better web experiences with this $29 UI/UX course bundle  The Next WebSimple, streamlined designs, consistent color schemes and a decluttered screen. Those are all tenets by which a strong web developer designs and builds.
Digital Marketing Underdogs: Quora and HARO [Case Study]  Business 2 CommunityMarketing is about getting noticed. In a world full of digital noise, this is easier said than done. But, it's not impossible. In addition to the connections you make ...
Google launches Flutter 1.2 and Dart DevTools, a web-based suite of programming tools  XDA DevelopersFlutter is one of the newest additions to the arsenal for app developers. It's a UI framework for building beautiful, fluid, and interactive cross-platform native apps ...
Front End Web Developer - Aceable  Built In AustinAceable is hiring for a Front End Web Developer in Austin. Find more details about the job and how to apply at Built In Austin.
7 Career Options That Don’t Require A College Degree  Thrive GlobalHaving a college degree is one of the best and easiest ways to land a job of desire. It is a common observation that students remain concerned about the quality ...
We're hiring! Web Developer/Programmer  Catholic OutlookThe purpose of the Web Developer/Programmer role is to ensure that the websites, intranet and other digital channels of the Diocese of Parramatta are ...
Why You Should Learn LAMP Stack Development?  TechnotificationIf you have handled a project on web development, you must have encountered with the term LAMP Stack. What is it and why should a programmer bother to ...
Microsoft's TypeScript programming language rising fast, almost makes top 10  ZDNetMicrosoft TypeScript is popular and it's here to stay as a prominent language, according to analyst RedMonk.
Explanation: The Rise Of Full Stack Developers  MobileAppDailyAfter an immense amount of research we have curated a suitable explanation on the rise of full stack developers in 2019.
Fast-growing web developer wins big at London chamber awards  The London Free PressA growing London technology business has been named large business of the year by the London Chamber of Commerce.
Hey Web Development Firms, Mercy Corps Wants A Knowledge Portal Built For Them In Zimbabwe  Technology ZimbabweMercy Corps, a US founded international humanitarian organisation is looking for a web development company to build a knowledge portal for some of their ...
5 useful Visual Studio Code extensions for Angular developers  Packt HubVSCode has become very popular among Angular developers for running Angular CLI. This post looks at 5 VSCode extensions useful for Angular developers.
10 Popular JS IDEs For Java Developers  Analytics India MagazineIntegrated Development Environment (IDE) is crucial while coding for larger programming projects as they help in handling the code smoothly.
Stop using Chrome, Install Brave Browser! Wikipedia Co-founder Tells You Why  Ethereum World NewsUser privacy and the risks associated with data leaks should be a priority for today's globalized society, and Larry Sander, co-founder of Wikipedia, is fully aware ...
Why this aspiring data analyst is looking for a mentor  Technical.lyRecent MBA-MIS graduate Renee Biggs is set to take on a new career. Now, she writes, she needs some guidance from a women who's been there. Why this ...
TypeScript’s Quiet, Steady Rise Among Programming Languages  WIREDMicrosoft's programming language TypeScript has become one of the most popular languages among developers, at least according to a report published by ...
Digital Marketing Manager/Jr. Web Developer (#19-019) Job Opening in Kenmore, Washington  Chief MarketerBastyr University is seeking a qualified candidate to fill the Digital Marketing Manager/Jr. Web Developer position. This person will collaborate with a team of ...
How to Select a Good eCommerce Web Development Company in 2019  Deadline NewsA good eCommerce web development company should have the same qualities you would look for in any business partner; knowledge, experience and ...
Benefits of Using Symfony in the Development of a Web Application for Your Business  The Future of ThingsIt is an inescapable fact that we live in an online world. In this world, any serious business that wants to get noticed and grow needs to have a web presence — a ...
What is going to be the next stage of evolution in web services and marketing strategy?  The Hans IndiaThe advancing business world has reacted effectively to web administrations and information examination Significantly greater ventures which dont depend ...
Catalyst Connect Expands Their Web Development Team to Offer Additional Services to Their Zoho Clients  PR WebPremier Zoho Implementation Partner, Catalyst Connect has announced the expansion of their Web Development Team and now offers Website Design and ...
Oxford dictionary adds ‘chuddies’ to list  The HinduThe word became popular after it was used as part of a catchphrase in a British television show.
Code Boot Camp: Augusta's next wave of web developers  WJBF-TVMore and more technology companies are moving to Augusta, making the city the hub of cyber command.
How to Develop an E-Commerce Mobile App  YourStory.comMany reasons to say “why having an e-commerce app is beneficial to businesses.” And how advantageable it is to have an e-commerce mobile app for your ...
Why Magento App Development is the Best Fit For Your Business?  YourStory.comThe platform that is making waves in the eCommerce development is Magento. It facilitated a spurt in the development of the native online application.
BJP website hacked, Narendra Modi memes added with Bohemian Rhapsody  India TodayMultiple social media users reported on Tuesday that the Bharatiya Janata Party's website was hacked, and shared screenshots of an unflattering meme ...
Meet Shavini Fernando, developer of a wearable vital monitoring device  Technical.ly DCFernando presented her product, OxiWear, at Georgetown University's second annual "Bark Bank" pitch competition last year and took home $35,000 in prizes.
Top Web Development Trends 2019  YourStory.comWeb Development Trends 2019 Do you know global internet users number have surpassed 4 billion in 2018? It is found in a recent study by We Are Social and ...
With its Elasticsearch distribution, Amazon Web Services sends more shockwaves through open-source software  GeekWireNobody really knows what lies ahead for the future of open-source software as cloud computing becomes the dominant force in enterprise tech, but the times are ...
The Crucial Role of AI in Web Development  Analytics InsightArtificial intelligence is undeniably no longer a buzzword in the web development space. AI in web development is used to design automation, integrating into ...
Vitalik Buterin: High Ethereum Price Good for Security, Ecosystem Development  CointelegraphNews. Ethereum (ETH) co-founder Vitalik Buterin says that high ether prices are important both for network security and the wider ecosystem's development.
Two Exchanges Overtake Binance on CMC Rankings, But Research Suggests Volume Is Fake  CointelegraphNews. Today, on March 21, both LBank and Bit-Z overtook leading exchange Binance on the adjusted trade volume cryptocurrency exchange rankings on ...
Brexit endgame: European Union takes back control  Brookings InstitutionAfter the British parliament defeated Prime Minister Theresa May's deal with the European Union for a second time in mid-March, it narrowly supported a request ...
Web developer offers services to city council | Local News | ncnewsonline.com  New Castle NewsNew Castle City Council expects to start rebuilding its website.
5 Ways in Which Data Science Is Revolutionizing Web Development  Analytics InsightTechnology is a highly dynamic field where new advancements keep coming every day. The data is the next big thing about this modern digital age.
Top 10 Image Formats That Are Best for Web Development  YourStory.comWeb application development is one of the biggest trends in this era because now a day's software has tons of functionality that cannot work properly on our ...
A Quick Primer on Managing Your Web-Development Tasks  EntrepreneurNeed to modify your website or app? Here are the tips you'll need to do that right.
Own database development with this MySQL bootcamp for $11  XDA DevelopersMySQL is the most popular database framework in the world, used by the likes of Adobe, Apple, Amazon and a bunch more companies that don't start with the ...
Do counter-narratives actually reduce violent extremism?  Brookings InstitutionParticularly since the rise of the so-called Islamic State in 2013, one of the most widely held theories in international political and policymaker circles has been ...
Cosmic JS wants to simplify web development so you can focus on content  TechCrunchIf you are a web developer, you know how complex many of the traditional web *content* management systems have been. One of the big problems has been ...
Are You Missing This Important Puzzle For Web Development Success? – Test Driven Development  YourStory.comAs a Web Development Company, there are many aspects of your business that determine your success. You can choose to create your application as cheap as ...
Web Development on an iPad  Laravel NewsThe idea of working entirely from an iPad has always appealed to me. The portability, the battery life, and of course the touch screen makes it an excellent device ...
Polymath, SeriesOne Team Up to Simplify Security Token Issuance  CoinDeskSecurity token platform Polymath has partnered with digital securities fundraising platform seriesOne to offer an “end-to-end” solution for security token issuance.
This $41 course package can get you hired as a back-end web developer  The Next WebFront end developers get all the glory. Their work is always right there in a user's face with all that HTML and CSS goodness. But those in the know know that the ...
Mid/Senior C# .Net Web Developer job, Cape Town, Woodstock  Bizcommunity.comAn exciting mid/senior position is available for a highly passionate and dedicated developer with experience in C#, SQL Server, HTML/CSS/jQuery.
How Artificial Intelligence is reshaping web designing and web development?  Express ComputerBy Ankit Gupta, CEO and VP, WeblinkIndia.net. The modern industries follow the consumer-driven approach, where customer experience has become the ...
Yale, Flatiron School create web development bootcamp for summer session  Yale NewsYale Summer Session is collaborating with Flatiron School to offer a Web Development Bootcamp for Summer 2019, which will carry two Yale College credits, ...
Google Forgets to Announce a Major Change – SEO Community Disappointed  Search Engine JournalGoogle announced a major change several years late. The SEO community reacts with disappointment.
What Skills Should You Look for in a Web Developer?  Customer ThinkIntroduction. Choosing a web development company is one of the most important decisions a business can make in today's marketplace. Simply put, how a ...
7 Web Development trends that will shape your online market now and beyond  TechGenYZHere we list out 7 unignorable web design trends to accelerate your growth this year. This will help you shape your online market.
9 Web development trends you simply cannot ignore in 2018  TechGenYZWeb development is a major part in conversions and increasing your sales.To optimize your websites know the web development trends of the year.
JavaScript and Web Development InfoQ Trends Report  InfoQ.comThis InfoQ Trends Report looks at the current trends with JavaScript, HTML, CSS, and web development, exploring technologies and options gaining further ...
Trends You can Expect in Web Development for 2019  Customer ThinkThe current generation of website developers is ideal employees in consideration of web development spectrum. Most of the modern people respond quickly to ...
Done Role of IoT in Web Development  Customer ThinkWith the increasing advent of technology and the ever-changing demands of people as well as businesses, there has been a rise in technologies which have ...
Constantinople Incoming: Today’s Two Ethereum Hard Forks Explained  CoinDeskIn less than 24 hours, the world's second largest blockchain by market capitalization is expected to activate its sixth and seventh system-wide upgrades, at which ...
Web Development: What's Big In 2019?  HackadayI try to keep up with web development trends but it's hard to keep pace since it's such a fast evolving field. Barely a week goes by without the release of a new JS ...
Score 9 courses on back-end web development for just $41  MashableAt the risk of sounding totally high: Websites are sort of like restaurants, when you think about it. Stick with us. You've got your front-end developers, who function ...
How IoT Is Changing Web Development  IoT For AllIoT brings changes to software development on many levels, including on the web. Let's discuss the main peculiarities and nuances of IoT web development.
How AI is reshaping web development | Articles | Big Data  Innovation EnterpriseHow AI is enabling are reshaping web development and giving developers everywhere hope about the future of tech.
Web development trends 2019 - Ponder on them to make a difference  ITProPortalThe world of web development experiences demand constant transformation every year, whether it is related to tools, services, coding, languages, or designs.
New Zealand to Ban Military-Style Semiautomatic Guns, Jacinda Ardern Says  The New York TimesCHRISTCHURCH, New Zealand — Prime Minister Jacinda Ardern of New Zealand on Thursday announced a national ban on all military-style semiautomatic ...
How will AI change the web development in future?  Customer ThinkAI is present everywhere – from chatbots to virtual assistants, AI is used in day to day activities. Virtual assistants like Siri and Cortana are helping the users by ...
Lean Web Development with the Best Teachers Online  Digital InspirationMeet the best online teachers for learning modern web development including React, TypeScript, JavaScript, Golang, Flutter, Nodejs, Docker and more.
Things You Should Definitely Know About Web Development Team  Customer ThinkImagine one time you came up with a great idea to create a website for your company. The first step to take in this case is to hire a web development team of ...
Django vs Flask: A Look At The Two Popular Python Web Frameworks  Analytics India MagazineIn this article, we look at two of the best frameworks, Django and Flask that can be used by Python programmers and developers.
Future of web development in India  Daily News & AnalysisFuture of web development in India - Web development, as a career, has witnessed a boom all over the world, including India, since the time e-commerce has ...
Careers in Web Development  Telangana TodayIn the last edition we have discussed about various technology stacks, what to learn and what is the career path. This article details about careers in web ...
Best Programming Languages For Backend Web Development  TechnotificationHere are some interesting server-side web development programming languages worth considering for web development.
Know about the current trends in web development  Customer ThinkIn case of web development, you may have probably heard that the only constant is the change. It is an industry-defining statement as web development keeps ...
How to become full-stack web developer  JAXenterIf you're looking for a way to become a full-stack web developer, and amplify your chances of landing a well-paid job, here is the ultimate guideline.
Learn Web Development for Free With App Academy  LifehackerCoding school App Academy has opened a free online interactive version of its 12-week curriculum. That's a pretty good deal, since the Academy's in-person ...
10 Essential Question to Ask Your Web Developer  Business.comAsking the right questions when choosing a web developer can help you find someone who understands your vision and can give you the website you want.
This Complete Full Stack Web Development Master Class Bundle only costs $29  NeowinToday's highlighted deal comes via our Online Courses section of the Neowin Deals store, where you can save 95% off the Complete Full Stack Web ...
Use Rust for web development [Tutorial]  Packt HubRust is efficient and has well thought web-oriented frameworks, making it viable for web development. In this article, we'll see how Rust can be used for web ...
Python Survey: Data Analysis Overtakes Web Development as No. 1 Use Case  ADT MagazineA new developer survey about Python reveals the programming language is now used primarily for data analysis, supplanting the previous No. 1 use case, Web ...
Learn the Essentials of Web Development with This eBook Bundle  Interesting EngineeringThrough hands-on, real-world instruction, this course teaches you about everything from development essentials like JavaScript, Java, and C++ to interview ...
Focusing on data science and web development, edtech startup edWisor looks to bridge the skill gap  YourStory.comBootstrapped edWisor looks to address skill shortage in the areas of data science and web development, and uses gamification to align freshers with industry ...
“ChromeOS is ready for web development” – A talk by Dan Dascalescu at the Chrome Web Summit 2018  Packt HubAt the Chrome Web Summit 2018, Dan Dascalescu, partner developer advocate at Google provided a high-level overview of ChromeOS and discussed ...
CoinMarketCap Crypto Indices Launch on Nasdaq, Bloomberg, Reuters  CoinDeskTwo cryptocurrency benchmark indices from data provider CoinMarketCap will launch today on financial data feeds from Nasdaq Global Index Data *Service* ...
You Can Become a Web Developer with This Interactive Coding Bootcamp  Interesting EngineeringWith over 60 hours of instruction led by industry professionals, this in-depth bundle will get you up to speed with the world's most important programming ...

Autoresponders Make You Look Like A Pro

People like to get immediate responses to requests. Autoresponders are... Read More

What is SQL?

What is SQL? SQL stands for Structured Query Language and... Read More

How One Word Or Even One Letter Can Boost Conversion Rates By Over 400%!

Recently I was reviewing the keyword specific conversion rate data... Read More

Why Should Your Business Go O.N.L.I.N.E.

Optimize your time. How much time each day must you... Read More

Topics to Add When Creating an Alternate and Modern Medicine Web Directory

Alternate medicine finds its own place in the hearts and... Read More

Web Accessibility: The Basics

What is web accessibility & why is it important?Web accessibility... Read More

Create Huge Income From Your Web Site - 10 Easy Ways

The cost of setting up a web site is dirt... Read More

Be Creative Before You Purchase Or Create A Website

Before you jump into spending coutnless hours on designing and... Read More

Web Content Strategy 101

Your content is what gets you in search engines, speaks... Read More

How Worldly is Your World Wide Web?

The growth in Internet usage around the world is astounding... Read More

The Problem with Paypal On Your Web Page

When I set up my website I felt paypal was... Read More

Building a Web Site Requires the Right Software to Eliminate Headaches and Keep Money in Your Pocket

When most people build a web site, they think one... Read More

How to Handle Web Surfers Who Disabled JavaScript

There are hundreds of millions of Web surfers today. Each... Read More

Do You Really Need A Website To Succeed

Rosalind wants to share her inspirational poetry with a wider... Read More

Is Your Website Innovative? Increase Your Business Over Night!

While studying online for IT investment opportunities, I found that... Read More

What Does An Ex-Basketball Coach Know About Pulling Web Metrics?

In my previous life.....Actually, my previous JOB life, I was... Read More

Writing Effective ALT Text For Images

Anyone who knows anything about web accessibility knows that images... Read More

How to Get a Knock Out Website!

The first step in setting up an online business...Starting an... Read More

Do Dancers Need A Website?

Dance is how you pamper your soul and satiate your... Read More

Let Your Customers Redesign Your Website!

When you purchase a new item from a Yahoo! Store,... Read More

The Most Important Aspect of Writing Web Copy

There is an ongoing debate about web copy. Some say... Read More

7 Killer Ways To Increase Your Online Sales

Every online entrepreneur I talk to is asking the same... Read More

Get a Website!, Register Your Domain!: To Website or Not to Website?

If you're fairly new to the Internet scene, you may... Read More

Creating Compelling Content , Write It and They Will Come

In a previous ezinearticles.com article,"I Need real visitors, Not Search... Read More

Where on Earth is Your Websitee?

You've just finished congratulating your marketing team. After six months... Read More