Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old October 31st, 2003, 06:43 PM
Authorized User
 
Join Date: Jun 2003
Location: Gulfport, Ms, USA.
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to hcweb
Default Record length ?!?

Hello all!
I'd like to query a database and upon displaying the record, I'd like to limit the actual visible length of that record.

i.e.:
"John ran around the world to try and catch himself" limited to "John ran around the world..."

Any help would be greatly appreciated.
  #2 (permalink)  
Old October 31st, 2003, 07:12 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

You can use the Left function to accomplish this:
Code:
Dim MyString
MyString = MyRecordset("AColumn")
Response.Write(Left(MyString, 25) & "...")
will write out the requested value.

If you don't want to break the string in the middle of a word (e.g. worl...), you'll need to do some extra searching in the string. I think the easiest way to do this is to use the Left function to limit the length of the text string. Then you can use InstrRev to find the last space character in the string. Then use the return value of InstrRev in combination with the Left function again, to cut the string at the last space position.

If you need more help with this, post a question here.

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
  #3 (permalink)  
Old November 1st, 2003, 11:16 PM
Authorized User
 
Join Date: Jun 2003
Location: Gulfport, Ms, USA.
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to hcweb
Default

Thanks Imar! Works like a champ!!


Similar Threads
Thread Thread Starter Forum Replies Last Post
length crmpicco Classic ASP Basics 1 February 11th, 2005 11:24 AM
How to get the "Length" of a column Guillermo Hdez ADO.NET 0 October 29th, 2004 07:31 AM
LENGTH OF TD viren_balaut Javascript How-To 1 September 8th, 2004 08:43 AM
length of label lily611 General .NET 6 July 22nd, 2004 02:00 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.