ASP Is Fun

Learning ASP
Free Course
Basics
Functions
SQL Commands
Sample Code

Servers / Setup
Host Reviews
Server Setup
Error Tips

Contract ASP
Development

Search For:



Intro to ASP


 


Concatenating Text in ASP



Some languages make you do complex functions to put together pieces of text. In ASP it's very easy, you just add the segments together.

If you had a variable called NumBooks, and wanted to show this to the user, you could simply do:

response.write "You have ordered " & NumBooks & " books so far."

Be sure to keep track of singular/plural issues when doing things like this. For example, in the above line you might actually want to say:

if cInt(NumBooks) = 1 then
BookStr = " book"
else
BookStr = " books"
end if

response.write "You have ordered " & NumBooks & BookStr & " so far."

Also be sure to keep track of spaces. You want to make sure that a space ends up between every word in your sentence!

I use string concatenation all the time when constructing SQL strings. If the user selects Item ID #295 and wants to get more information on it, I might then say -

SQLText = "Select item_name, item_desc from items where item_id = " & ItemID

and use that SQLText to do my query.

ASP Text Parsing Code


ASP Main Page | ASP Ebooks | Free ASP Course | Contact Lisa
All content copyright © 2010 Minerva WebWorks LLC. All rights reserved.

Italian Wedding


Free Newsletter!

Ebooks
Intro to ASP
ASP SQL DB
Members
Shopping


Introduction to ASP

Romance Tips
Irish Romance
Italian Romance
French Romance

ASP Poll
How do you handle 500 errors?
I don't
Page does nothing
Displays error
Emails error