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:

Top 5 editors / Text IDEs for web programming  ToolboxIn web developers, there is always a need to find the best web development tool. It can be a text editor, a specific framework for project creation, etc. I will focus ...
The 7 myths that hold back agencies from growing web development  AdAge.comPantheon shares lessons from its partner network of over 2500 agencies to dispel the seven most common myths about growing your web development and ...
@Pika/web Frees Modern Web Development from the Complexity of Package Bundling  InfoQ.compika/web, part of the pika tool chain, aims at improving web application developers' experience by turning often-complex bundling processes into an opt-in ...
This $29 bundle can get you savvy with Google’s own programming language  The Next WebYou may know that Google processes over 3.5 billion search requests per day, owns YouTube, and is a regular entrant on Fortune's list of the Best Companies ...
How To Find A Stellar Web Development Agency  ForbesWhen you're looking to hire an agency, act as if you're hiring an employee.
Key Things to Know About How to Hire Web Developer in 2019  Demotix.comThe last but not the least point is selecting a location from which you will hire web developer by rates that coders charge on average. Recruiting locally i.
Know About Role of PHP In Web Development  Customer ThinkIt is a well-established fact now that for any company to flourish it needs to have its presence on the digital platform. While social media can be the right place to ...
Web Development Company NYC, Huemor, Lists and Explains the Elements of an Effective Website  PRNewswireNEW YORK, June 21, 2019 /PRNewswire/ -- Three out of four brands are unhappy with their website redesign. With so many considerations going into a website ...
Why use Vue.js for UI web development?  JAXenterIf you are looking to start a new project and you are not sure if Vue.js would be the right choice for you, check out this overview of the popular framework.
IoT in Web Development Market 2019 to Witness Astonishing Growth With Dot Com Infoway Limited, Upwork, GoodFirms  Market Research ReportIoT in Web Development Market Research report presents a complete assessment of the market and contains a future trend, current growth factors, attentive ...
IoT, the Real Game Changer of Web Development!  CIOReviewFREMONT, CA: With the growing emergence of technology and the evolving requirements of individuals as well as companies, there has been an increase in ...
Obsessing over first-page load time sabotages ecommerce businesses  The Next WebA flawed approach to page speed measurement is sabotaging ecommerce sites. There, I said it. Now I know this might be an exaggeration, but it really is time for ...
PHP VS JAVA: Which Is The Best Option For Web Development?  Promotion WorldDifference Between PHP VS JAVA To develop a website, the developers need a programming language which is best suited. PHP and Java are the most.
This cheap online course will teach you all about front-end web development  MashableInteractive buttons. Scannable layouts. Flashy graphics. Beautiful typography. Elements of a website — or any digital product for that matter — that make you go ...
Web design and development  IndivigitalWe build user-friendly websites that help small brands standout in competitive marketplaces. We believe a website should and can be more than an obligatory ...
Website Development Handoff Checklist: What Your Developer Needs to Be Successful  Business 2 CommunityWebsite mockups are completed and client-approved. Pages and templates have yet to be built. It's time for a website development handoff. A website ...
5-Step Web Design Process to Create Winning Websites  Business.comA stellar design isn't merely focused on how pretty the interface looks.
Web Application/Database Developer - Custom Products - Motorola Solutions  Built In ChicagoMotorola Solutions is hiring for a Web Application/Database Developer - Custom Products in Chicago. Find more details about the job and how to apply at Built ...
KSM Consulting Acquires Web Development Company  Inside INdiana BusinessIndianapolis-based KSM Consulting is adding to its portfolio. The firm, which specializes in technology, data analytics and management consulting, has acquired ...
Edge, Chrome, Brave share updates on upcoming releases, recent milestones, and more at State of Browsers event  Packt HubLast month, This Dot Labs, a framework-agnostic JavaScript consultancy, conducted its biannual online live streaming event, This. JavaScript – State of ...
We’re Hiring A Visual Journalist To Cover Sports, The 2020 Election And More  FiveThirtyEightFiveThirtyEight's graphics and interactives team is growing! We're looking for a savvy visual journalist to contribute to daily graphics production, collaborate…
Django Vs Flask: A Detailed Comparison Between Python's Most Popular Frameworks  Analytics India MagazineHere is a detailed comparison between the two web frameworks of Python called Django and Flask.
Internships 2019: Applications open for internship with Department of Health & Family Welfare, Delhi  Scroll.inThe last date to apply for the 3-month internship for 'Project Connection-Aid' is 24 June, 2019.
Top 5 Programming Languages For Machine Learning  TechopediaWhile there are several programming languages that work especially well for machine learning, each of them comes with unique advantages and ...
WP Engine to Acquire Flywheel  Business WireWP Engine today announced it has entered into a definitive agreement to acquire Flywheel.
Senior Developers earn an average $109,957 per year—here are 9 other top tech jobs for new grads  CNBCUsing data from its platform, jobs site Comparably examined thousands of anonymous job records submitted by employees to see which tech jobs are the most ...
Best Web Development Company 2019 - Customer Experience – Winners at DCE Awards  IT News OnlineMumbai, India, June 05, 2019 --(PR.com)-- Website Developers India Pvt. Ltd. is the proud winner of the Best Web Development Company 2019 - Customer ...
What is the web development lifecycle?  NewsPatrollingWeb Development Lifestyle is a definite difference in the general framework for developing any application development project. Complying with the same.
Angular JS - The robust Java Script Platform with New Features and Updates  Siliconindia.comAngularJs is a popular JavaScript-based open source web application framework that supports the development of rich HTML web...
Meet Matt Slack: Michigan techie who is @slack on Twitter got an invite to Slack’s public debut  GeekWireMatt Slack has been on Twitter for 13 years with the handle @slack. Slack, the chat-based collaboration app, has been on Twitter for six years with the handle ...
Save 92% on the Complete Front-End Web Development Course  Geeky GadgetsWe have a great deal on the Complete Front-End Web Development Course in the Geeky Gadgets Deals store today, you can save 92% off the normal price.
8 JavaScript Frameworks Programmers Should Learn In 2019  Analytics India MagazineMost popular websites used JavaScript as their web framework. Here are the top 8 JavaScript frameworks for web development, in alphabetical order.
Web Accessibility Statement | University  Southern Miss NowThe University of Southern Mississippi is committed to being an inclusive community where everyone is encouraged to participate in our programs and activities, ...
JRNI opens web development office in Manchester | Business  The Union LeaderMANCHESTER — A customer engagement company whose clients include U.S. Bank, LEGO, Nordstrom and Levi's has chosen the Queen City for its web ...
Google engineer, drag queen, coding teacher: Meet Anna Lytical, a YouTube star teaching HTML and making programming more inclusive  INSIDERA Google engineer is using his drag persona to teach novices how to code on YouTube. The engineer, Billy Jacobson, began performing as "Anna Lytical" ...
A data scientist dedicated to social change  MIT NewsMIT Sloan MBA student Mason Grimshaw seeks to bring business solutions to overlooked communities, including the Rosebud Sioux Indian Reservation where ...
LKCS Receives Three Awards for Outstanding Web Development Projects  PR WebPeru, IL (PRWEB) May 28, 2019 -- LKCS has received three Awards of Distinction from the Communicator Awards for outstanding website design and ...
Web Development New York Agency, Huemor, Reviews Two Ecommerce Pages and Discusses What They've Found  The Chestnut PostNEW YORK, June 19, 2019 /PRNewswire/ — As a customer, think about how important the design of an ecommerce website is. If it's difficult to find what you're ...
Top 3 free courses on web development using WordPress  TechJuiceWe have compiled 3 free courses which will help you make your first website using WordPress.
Automated cryptocode generator is helping secure the web  EurekAlertNearly every time you open up a secure Google Chrome browser, a new MIT-developed cryptographic system is helping better protect your data. In a paper ...
UK-based firm opens web development office in Manchester  New Hampshire Business ReviewCustomer engagement company JRNI Inc. has opened its first U.S. web development office at 66 Hanover St. in Manchester, part of what it calls an aggressive ...
Neo-Nazis on DeviantArt Radicalized a Woman Who Planned a Mass Shooting  VICEThe cutesy art site was the surprising birthplace for a number of players in the modern extreme-right movement.
Web developer Wix creates 100 jobs as Dublin office opens  Newstalk 106-108 fmA cloud-based web development platform has created 100 jobs in Dublin with the opening of its new...
Cashscript Is Coming, Bringing Ethereum-Like Smart Contracts to Bitcoin Cash  Bitcoin NewsCashscript is a high-level language which can enable basic smart contract functionality on the Bitcoin Cash (BCH) network.
FiveAI hits the streets of London, the state of autonomous vehicle industry in Europe: Will the slow and steady win the race?  Silicon CanalsAutonomous vehicles are a part of the tech-infused future we are all envisioning to be a part of. Imagine a scenario where you are ready to go to work and ...
Coding boot camp kicks off new partnership  Mirage NewsWith demand for skilled tech talent in Australia at an all-time high, the University of Adelaide and workforce accelerator Trilogy Education are...
Google study aims to improve decision making behind web feature deprecation  The Daily SwigThe appliance of science. Google has teamed up with academics in an effort to create a more systematic approach to web feature deprecation. Deprecation ...
Waitr founder, CEO Chris Meaux named regional Entrepreneur of the Year  The Daily AdvertiserThe award qualifies Meaux for Entrepreneur of the Year 2019 National Award, to be announced at Entrepreneur of the Year National Awards gala.
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 ...
A new coding boot camp designed for adult learners is soon to kick off at Adelaide University  The AdvertiserAdult learners who want to break into the coding sphere are being offered an alternative route into the profession through a new course being offered at ...
‘I code in my dreams too’, say developers in Jetbrains State of Developer Ecosystem 2019 Survey  Packt HubLast week, Jetbrains published its annual survey results known as The State of Developer Ecosystem 2019. More than 19000 people participated in this ...
Highest paying part-time jobs in Singapore – The Independent News  The IndependentTutors who have credentials from top learning institutions and who are able to teach the most difficult subjects could be earning as much as S$100 per hour.
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, ...
Things to consider before going into web development  JAXenterWe normally don't offer beginners' guide for aspiring developers but this time around we are making an exception! Amit Jat has a set of extremely useful ...
McMinnville, OR Business Owner Recognized by Prestigious Goldman Sachs 10KSB Program  PR WebSacred Fire Creative, a McMinnville-based digital marketing agency founded in 2014 by Malee Ojua, has been named one of the most promising small ...
Internshala Trainings launches The Web-Dev Battle - A web development contest  Knn IndiaInternshala Trainings has launched The Web-Dev Battle for the students who are passionate about building their ideas from scratch using their creativity and ...
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 ...
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 ...
What you should know before hire a web developer for your WordPress site  Best in AustraliaBefore meeting with web developers, be sure to ask the following questions of any prospective WordPress web developer for wordpress web development.
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.
Solve Web development issues to Drive Business to Your Website  Customer ThinkHave you ever had to develop a website? I do not mean to sit down to program it but have to, at least, order it and work with the person or team that carries it ...
What makes Laravel the most Preferred PHP Framework for Web Development  Customer ThinkOne of the most daunting tasks for any business is choosing the right PHP development framework to build a robust web application. PHP frameworks are not ...
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.
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 ...
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 ...
Stefan Judis, a Twilio web developer, on responsible web development with HTTP headers  Packt HubAt this year's JavaScript Fwdays, Stefan Judis, who works at Twilio as a frontend developer, talked about how web developers can make their sites secure with ...
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 ...
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.
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.
Top 12 Python Web Frameworks of 2019 Programmes Should Know  Analytics India MagazinePython is a very versatile programming language. A new developer survey about Python by the Python Software Foundation and developer tools vendor ...
Internshala Trainings launches The Wed-Dev Battle — A web development contest  APN NewsAn opportunity for the students of India to learn the top in-demand skill and earn rewards worth INR 1 lakh. Internshala Trainings has launched The Web-Dev ...
AI Needs to Develop to Impact Web Design  Business.comArtificial intelligence has had a big impact on web design and development, but it still has a long way to go.
Harness web development skills to create better desktop applications  The GuardianIntegrating best of breed desktop applications from Adobe Creative Suite with web tools can provide a better experience for creative staff. Sakib Supple.
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 ...
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 ...
Learn Full-Stack Web Development With 80% Off This JavaScript Bundle  InverseThis E-Degree program has been designed as a one-stop solution for learning web development with JavaScript and other crucial programming languages.
App Development and Design Trends that will mark 2019  YourStory.comIntroduction One of the most significant technology markets is the mobile application division as proven by the Statista report that predicted that mobile apps ...
Controlism IT Solutions: Web Development 360 Degree  Siliconindia.comIT empowered solution small, medium and large organizations worldwide which executes innovation to transform their thoughts into activities.
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 ...
Creative UI/UX approaches to deliver high-performance Web Development solutions  Customer ThinkOver time, software design has had different approaches that have evolved and become enriched both in their tasks and in the variety of possible techniques to ...
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 ...
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.
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, ...
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 ...
Looking For Coding Jobs? These 8 Programming Languages Are In Highest Demand Right Now (2019 Data)  Trak.inCoding jobs are evergreen jobs: But the platforms keep on changing. Here are the 10 programming languages which are in highest demand right now (2019 ...
.NET 5 arriving in 2020!  Packt HubYesterday, on the first day of Microsoft Build 2019, the team behind .NET Core announced that .NET Core 3.0 will be .NET 5, which will also be the next big ...
.NET Core releases May 2019 updates  Packt HubThe team at .NET Core released the .NET Core May 2019 Update. The updates include security, reliability fixes, and updated packages.
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 ...
10 Topmost Web Design & Development Companies in Chennai – 2019 [Updated List!]  YourStory.comThe list of Top 10 Web Design & Development Companies in Chennai is sorted out through a research methodology. These companies are well verse in Web ...
Master web development with this JavaScript master class  Boing BoingWhen it comes to website development, JavaScript is the language that underlies it all. If you want to learn that language well enough for a career, you'll need ...
JavaScript and machine learning: Google shows what's possible using the web programming language  TechRepublicFrom head-controlled Pacman to browser-based upload filters -- here are some of the best uses of TensorFlow.js.
6 Software Development Concepts You Can Learn Through Online Courses  TechopediaWhen it comes to understanding the process of software development, there's a lot to learn. These courses can help you up your software development game.
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 ...
Eclipse announces support for Java 12  Packt HubThe team at Eclipse announced that Eclipse now has support for Java 12.
Ten Basic Things Every Web Developer Should Know  HTML Goodiesten things you need to know if you plan to build a web site.
How to reach smartphone users through your eCommerce business?  YourStory.comThe advancement in technology has led to various developments that the human race would have never thought about, and one of them is the eCommerce.
Decoupled Drupal Delivers Flexible Approaches to Web Development - Free eBook  NeowinMeet new experience mandates across channels and devices with flexible decoupled development modes provided by Acquia and Drupal. You can claim your ...
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.
Web Development Issues: 7 Reasons Why Your Website Isn’t Driving Business  Business 2 CommunityIs your website failing to drive business? You may be having problems with your web development. Read more here. website development. You launched your ...

Establishing Your Web Presence

Part of the success of most home-based businesses is their... Read More

Top 7 Tips for Building an Antique Car Website

Like wine cars get more attractive to collectors as years... Read More

Frequent Business Question: How Do You Start a Web Business?

Today it seems everyone is jumping on the entrepreneur bandwagon,... Read More

What is SQL?

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

Build a Web Site that Works...Even for a Safari Hobby!

My life's greatest passion is a safari hobby. And what... Read More

Bring Your Visitors Back Clamoring for More! Maintain and Improve Your Web Site Weekly - Part 1

80% of your Web site is Maintenance!Once your Web site... Read More

Get to Know People through Websites

Web sites are not just places to sell things; they... Read More

How to Get a Better Web Site ROI

Better Web Site ROIHow to increase your business profitability by... Read More

7 Tips to Make Your Order Page Work Harder

So your prospect, Mary, is sitting at the computer reading... Read More

Direct Sales and Your Corporate Website - A Creative Marketing Plan that Works!

Creatively marketing your corporate site takes time in the set... Read More

If You Build It, They Will Come?

Building a new website can be a lengthy task. From... Read More

Your Website Should Be Selling

It may come as some surprise to a traditionally off-line... Read More

Do You And Your Website Have Credibility?

I recently received an unsolicited e-mail from some company offering... Read More

Ten Quick Tests To Check Your Website For Accessibility

The Disability Discrimination Act says that websites must be made... Read More

Why Is No-one Buying From My Website?

Are you, like many other website owners, frustrated at the... Read More

Top 10 Webmaster Challenges

Webmasters deal with a myriad of complex design challenges every... Read More

Ten Ways NOT to Set Up a Website-based Service Business

1. As the first step, "Hire a web designer."First create... Read More

Trinkets, Lockets And Empty Pockets

It never ceases to amaze me how many people set-up... Read More

1 Simple Solution to All Internet Marketers about Their Website Design Needs

It is an undeniable fact that not everybody is keen... Read More

Building a Web Store on Shoestring Budget in less than Four Hours

Starting a business online is no longer as difficult as... Read More

Build It and They Will Come

Build it and they will come is not always true;... Read More

Why You Need a Website

You hear a great deal about the Internet these days... Read More

The Web: Your Window of Opportunity

Thinking about starting up a business? The web is the... 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

From Concept to Website

You've decided to create a website to market your products... Read More