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:

Profile In Success: atCommunications Marks Two Decades of Excellence in Web Development and Digital Marketing  EIN NewsAs technology has evolved over the course of the last two decades, so have firms like atCommunications that create *content* for it.
Tripti Tiwari defies the small-town definition of 'good girl' to start up CloudTrains Technologies  YourStoryWhen Tripti Tiwari was growing up in the small town of Gwalior, she was often fed the scary narrative that “good boys” become powerful and responsible men ...
IoT: Revolutionizing the web development sector with  JAXenterIoT is a diligent technology that has totally transformed our daily lives. But how has the technology affected web developers? In this article, we attempt to ...
How to Set Up a Raspberry Pi Web Server - Tom's Hardware  Tom's HardwareOne of the most popular uses of the Raspberry Pi is as a web server that lives on your local network. Whether you need an Intranet for your office or a small ...
Why Is WordPress The Top Choice In Web Development? Let Us Count The Ways  HostReview.comWhen a business takes the time to meet with an app development company, a number of questions are going to come up. An app development company can ...
Web Development New York Agency, Huemor, Discusses the Top Conversion-Boosting Techniques You Should Pay Attention to For Your Ecommerce Website  Yahoo NewsConversions are an essential measure of success for any ecommerce website. If your conversion rate doesn't increase (or hold constant) with higher levels of ...
O'Reilly Partners with Netlify to Publish Free E-Book: Modern Web Development on the JAMstack  WP TavernIf you are following the JAMstack (JavaScript, APIs, and markup) craze and want to learn more about the history and best practices of the architecture, O'Reilly ...
Experts at Revelation Discuss How O4W Can Transform MV Web Development  Database Trends and ApplicationsRevelation is known for its OpenInsight NoSQL MultiValue database development suite that provides Windows, Web 2.0, and .NET tools to develop and deploy ...
How to Work Effectively with Your Overseas Web Developer  Business 2 CommunityAccording to Global Workplace Analytics, “The remote workforce has increased by 140% since 2005.” The remote, digital work space has dramatically changed ...
The Benefits of WordPress Multisite for your Web Development Project  Coast DigitalSometimes a web project requires room for growth. You might have a large amount of *content* which requires careful differentiation and organisation; a website ...
ADA Reveals List of Top Web Development Companies in India  EIN NewsHere is the periodic list of India's most innovative companies in web development by ADA, check them out.
PHP plus: P++ proposal would create a stricter dialect  InfoWorldA new dialect of PHP, code-named P++, could be developed as a stricter variant of its dynamic predecessor, with more advanced features and less baggage.
Low-Code Has Taken Development by Storm. Why Not the Web?  DevOps.comFor more than a decade, development tools increasingly have made their way into the hands of less-technical people. On the web in particular, we've eliminated ...
Kickstart Your Career in Coding and Development with These 5 Bundles  Interesting EngineeringIt should come as no surprise that learning how to code is one of the most important things you can do if you want to land a lucrative career in virtually any ...
5 ways AI is empowering web app development  KnowTechieThese are some of the main ways in which AI is influencing web app development and making it more efficient.
What Makes Laravel Development A Preferred PHP Framework for Web Developers?  Customer ThinkWebsite development is a crucial part of technological development. Websites give individuals and corporates a presence on the internet. The sites also act as ...
GoodFirms Unveils Reliable Web Development Companies for Major States & Cities of USA for Q2- 2019  PRNewswireWASHINGTON, July 23, 2019 /PRNewswire/ -- Website is a strategic asset for a business. It is imperative to build a unique and attractive site to stand out of the ...
The Role of JavaScript in Web Development  Coast DigitalJavaScript is growing every day and our job as developers is to grow with it. This post takes a look at the role of JS in web development.
Web Developer job with Lebanese American University | 401526  mediabistro.comWeb Developer Consultancy. For Lebanese American University New York Headquarters and Academic Center (LAU NY). OVERVIEW. The Consultant will be ...
How to Transition to Become a DevOps Engineer  DevOps.comYou've either heard the buzzword or you've seen the extensive list of rewarding aspects that come with being a DevOps engineer. Whatever the reason you're.
5 alternatives to JavaScript for front-end development  JAXenterJavaScript isn't for everyone, but what are the alternatives? In this article, Future Hosting's Matthew Davis looks at 5 of them and weighs the pros and the cons.
App Marketing  App Developer MagazineiOS App Developers London App Developers Los Angeles App Developers Mobile Ad Network. Featured. Verified. Visit Website ...
The problem with choosing a popular generic company name  Domain Name WireThe brand Theorem is a crowded brand. Picture of man looking at confusing array of documents on a wall with words Brand Confusion. A company called ...
5 tips on selling on social media without driving people away  Born2InvestSocial media is one of the best marketing tools out there: you can grow and reach a large audience with *content* and ads, and people who like and/or follow you ...
Web Developer (Full-Time) job with Wilmington University | 402445  mediabistro.comWeb Developer. Wilmington University. Employment Status: Full time. Location: Wilson Graduate Center. department: University Relations. Effective ...
Web Development New York Agency, Huemor, Gives Insights About What It Takes to Be a Successful Web Developer  Yahoo FinanceNEW YORK, July 18, 2019 /PRNewswire/ -- In our growing digital age, the career of web developing has seen one of the biggest booms of any field. Once a ...
Web Development Company in NYC, Huemor, Discusses the Difference Between Web Design vs. Web Development  Yahoo FinanceNEW YORK, July 24, 2019 /PRNewswire/ -- Though the two terms are used interchangeably, "web design" and "web development" describe different tasks in a ...
Global Virtual Staffing Company Provides Specialist VAs for Clients Needing Help with Technical and Creative Tasks  PR.com20Four7VA Offers Specialist VA Services for Digital Marketing, IT Development, *Content* Development, and Creative Design Tasks.
What You Need To Know As A Web Developer  OxGadgetsAnyone who writes code for a living or a hobby will tell you, web development can be hard, complex and time-consuming however the majority will tell you that it ...
Front end web development internship in North Holland, Amsterdam  IamExpat in the NetherlandsDTT is hiring a Front end web development internship in North Holland, Amsterdam. Are you an expat looking for jobs in English? Apply now!
Ionic React RC is now out!  Packt HubEarlier this year, the Ionic team released the beta version of Ionic React. After receiving the developer feedback and contributions from the community, the team ...
EverWash | Junior Web Developer  Technical.lyEverWash is now hiring for the position Junior Web Developer in 1 Winding Dr, Monroe Building Suite 100, Philadelphia, 19131.
Junior Front End Web Developer job with Fox Corporation | 402049  mediabistro.comJunior Front End Web Developer in New York , Experienced (Non-Manager), Web Production, Creative & Design with Fox Corporation. Apply Today.
13 free tools for API design, development, and testing  InfoWorldThe rise of RESTful APIs has been met by a rise in tools for creating, testing, and managing them. Whether you're an API newbie or an expert on an intractable ...
Top 5 Reasons to Take Web Developer from Outsourcing Specialized Company in 2020  Programming InsiderWeb development is one of the most software engineering fields where the demand for web programmers is continuously increasing worldwide. With the ...
Why industrial websites benefit from WordPress web development  Best in AustraliaWhether an industrial website needs to be updated or constructed, there are a number of reasons to rely on WordPress web development.
Former Grant Union student offers web development, design  Blue Mountain EagleJohn Day resident Harsh Patel, a former Grant Union student and recent Boston University graduate, is jumping into real-world entrepreneurial experiences.
Your Digital Storefront: Outsourcing Your Self-Storage Website Development  Inside Self-StorageIf you're looking to build a new self-storage website or improve an existing one, consider outsourcing to ensure all important bases are covered.
70 Web Design and Development Terms We Wish You Knew, Part 2  Business 2 CommunityIn Part One of this two-part post, we gave you some definitions and comments for terms we use here every day. I broke it into two parts because it was getting ...
Top 6 Frameworks and Tools To Build Progressive Web Apps  AppinventivWe have curated a list of the best frameworks for PWA for entrepreneurs struggling with the choice. Know which PWA frameworks and tools made it to our list.
Study Web Development or Games Programming at SAE London  Hackney CitizenSAE London delivers industry-focused 2-year creative media degrees and 1-year diplomas in Animation, Audio, Film, Games Programming, Music Business and ...
Arizona STEM Teachers Return to Class After Summer in Industry  UANewsAs Arizona students head back to class in August, so too will a group of about 50 middle and high school teachers who spent the summer working in industry as ...
Senior.Net Full Stack Developer job with American Nurses Association | 402214  mediabistro.comThe American Nurses Association (ANA) is the premier organization representing the interests of the nation's 4 million registered nurses. ANA advances the ...
Securing modern web apps: A case for framework-aware SAST  Help Net SecurityIf you were to write a web application entirely by yourself, it would be a rather daunting task. You would need to write the UI elements from lower-level APIs, set ...
Global Virtual Private Servers (VPS) Web Hosting Services Market 2019 Top Company - Namecheap, InMotion Hosting, Hostwinds, Liquid Web -  Report HeraldGlobal Virtual Private Servers (VPS) Web Hosting Services Market Overview: The market study titled Global Virtual Private Servers (VPS) Web Hosting Services ...
The Top Medical Development Agencies Of 2019, According to SDCR - Top Software Development Companies  PR WebStudies reveal that 18 percent of patient records within organizations are duplicates. Luckily, SDCR – Top Software Development Companies determined the top ...
How to create a website with Google Sites  TechRadarSites is a Google *service* that helps you create websites. You can use the freely available web *service* to create dynamic and interactive websites with just a few ...
Beyond Ginsters: Samworth Brothers launches website for new food-to-go service  ResponseSourceUK food manufacturer, Samworth Brothers, aims to corner the lucrative food-to-go market with the launch of its website for new retail food brand, *Fresh* Food for ...
OpenTracing and OpenCensus merge into OpenTelemetry project; Google introduces OpenCensus Web  Packt HubGoogle's OpenCensus Web is a library for measuring application performance of web pages.OpenTracing and OpenCensus merges into OpenTelemetry.
Job Posting: Blue Jays Web Developer  FanGraphsWork closely with the entire Baseball Operations department to design and develop new applications to help support the decision process around player ...
New Business Wins for Access Prompt Four New Appointments  BdailyAward winning creative agency, Access has strengthened its team with four new hires following a string of new business wins and being awarded new projects ...
The Best Custom Website Design Companies From Around The World, According To DesignRush  PR WebDesignRush discovered the top website design and development agencies who can build custom platforms for businesses of all industries, successfully solving ...
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, ...
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 ...
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.
Current Big Trends in Web Development  HTML GoodiesHow many of these big trends are you using in your web site development today?
Yes, You Will Need a Magento Developer!  ExplosionEcommerce platforms remove a lot of the hassle that comes with building your own website from scratch. This allows startups to prosper and establish.
Two worthy books trace the history of tech through Silicon Valley, leaving Seattle’s story still to be told  GeekWireEditor's Note: In this guest post, Tom Alberg, Madrona Venture Group managing director, reviews The Code: Silicon Valley and the Remaking of America by ...
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 ...
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 ...
How To Find A Stellar Web Development Agency  ForbesWhen you're looking to hire an agency, act as if you're hiring an employee.
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 ...
@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 ...
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 ...
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.
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 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 ...
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.
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 ...
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 ...
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 ...
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 ...
Head of Web Development job with QUEEN MARY UNIVERSITY OF LONDON | 175514  Times Higher Education (THE)Department: Marketing & Communications Salary: £46,489 - £51,899 per annum inclusive of London Allowance (Grade 6) Location: Mile End Closing date: ...
Web development: So many choices to get the right fit  SDTimes.comOn one hand, the web today provides a wealth of information, giving developers easy access to a number of resources useful when running into a problem or ...
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.
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 ...
Vital points to consider while choosing the platform for website development  ITProPortalSelecting the best platform for your website is an absolute requirement for your business, but choosing the right platform isn't that easy.
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.
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 ...
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.
Tips to Boost Your E-commerce Sales  Business.comIncrease your online store's sales with these 10 helpful tricks.
The Complete Front-End Web Development Course  InverseThe Details. Start learning in-demand programming skills & tools; Access 117 lectures & 14 hours of *content* 24/7; Dive into web development basics w/ HTML ...
Complete 2019 Web Developer Bootcamp: Build 15 Projects for only $15  NeowinToday's highlighted deal comes via our Online Courses section of the Neowin Deals store, where you can save 95% off this Complete 2019 Web Developer ...
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 ...
Thrive Creative Group wins 2019 IAC Best Website Award  Clarksville NowCLARKSVILLE, Tenn (CLARKSVILLENOW) – Thrive Creative Group, LLC has won the Best Military Website for Campbell Strong Defense Alliance in the 2019 ...
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 ...
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 ...
Top 12 Python Web Frameworks of 2019 Programmes Should Know  Analytics India MagazineHere are the top web Python frameworks of 2019.
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 ...
NativeScript 6.0 releases with NativeScript AppSync, TabView, Dark theme and much more!  Packt HubThe team behind NativeScript announced the release of NativeScript 6.0. This release features faster delivery of patches with the help of NativeScript AppSync ...
5 Ways in Which Data Science Is Revolutionizing Web Development  Analytics InsightCustom software development companies are figuring out new ways to utilize the advanced data science techniques to build customized websites to suit specific ...
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 ...
How IoT Affects The Future Of Web Developments  ReadWriteATMs, Apple Watch, Fitbit, Self-driving cars and more are part of a list of devices using IoT is endless. The concept of IoT began years ago; we just didn't use the ...
[Jobs roundup] Be a part of the virtual and augmented reality revolution with these openings  YourStoryThe biggest innovations in technology will fuse the real and virtual world digitally. You can be a mover and shaker in the AR and VR universe with this coveted ...
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, ...
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 ...
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 ...
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 ...
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 ...
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.

Profitable Websites for Exclusive Industries

In the region where my company is located, South Bend,... Read More

Abandonment - Why Visitors Don?t Turn Into Customers

Every good Internet business understands the value of conversions versus... Read More

Why Every Small Business Owner Needs Two Websites

Every small business owner knows that they need a website,... Read More

Web accessibility for screen magnifier users

The needs of screen magnifier users are overlooked when implementing... Read More

Website Imperatives and Solutions

When you take a look at the most visited sites... Read More

Increase Your Affiliate Earnings with a Smart Webmaster Plan

Affiliate programs are a great way to earn an income... Read More

Are You Overlooking the Benefits of Using Sub-Domains within Your Web-hosting account?

One of the most useful features offered by some web... Read More

How to Get a Better Web Site ROI

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

The Birth of a Professional Web Site

The Internet has opened a whole New World of opportunity... Read More

Where on Earth is Your Websitee?

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

Live Support from Your Website? Can You Do It for Free?

I'm a freelance programmer and somehow I managed to get... Read More

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... Read More

The Web: Your Window of Opportunity

Thinking about starting up a business? The web is the... Read More

Having a Portfolio on the Internet Can Help you Infiltate the Workforce

If you're an up and coming graphic/web designer just out... Read More

I Did It: Six Months to a Successful Website

For years now I've been looking to start my own... Read More

Business Website Building Do?s and Don?ts

First, using a lot of web graphics, flash, banners and... Read More

Ten Quick Tests To Check Your Website For Accessibility

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

Content Management

More and more businesses are recognizing the importance of content... Read More

Making Your Website Shine! Attract and Keep Visitors at Your Site!

When you consider the billions of individuals and companies on... Read More

3 Rules of Website Designing and Layout

Now that you have got your domain name registered, your... Read More

Build It and They Will Come

Build it and they will come is not always true;... 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

Let Marketing Manage Your Website Content

The definition of the phrase "Content Management" depends on what... Read More

Now You Have a Web Site - Have You Ever Heard of Accessibility?

An accessible Web site is easily approached, easily understood, and... Read More

The Number One Reason Most Websites Fail

Failure, just like success, is measured differently by each and... Read More