Code Bank
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingCode Bank

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old June 7th, 2006, 06:31 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
Click here for more information.
 
Join Date: Sep 2004
Location: Israel
Posts: 26,942 Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)  Folding Points: 340933 Folding Title: Super Ultimate Folder - Level 1Folding Points: 340933 Folding Title: Super Ultimate Folder - Level 1Folding Points: 340933 Folding Title: Super Ultimate Folder - Level 1Folding Points: 340933 Folding Title: Super Ultimate Folder - Level 1Folding Points: 340933 Folding Title: Super Ultimate Folder - Level 1Folding Points: 340933 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 1 Week 5 Days 12 h 47 m 26 sec
Reputation Power: 1537
Post Vbscipt/classic ASP - show first x chars and preserve last word

little fuction that will crop the given string after x characters
but preserve the last word:
Code:
Function CropStringAt(strString, iLettersAmount)
	Dim result, x, curChar
	result = Left(strString, iLettersAmount)
	x = iLettersAmount+1
	Do Until x>Len(strString)
		curChar = Mid(strString, x, 1)
		If (curChar=" ") Or (curChar=",") Or (curChar="-") Or (curChar="(") Or _
			(curChar=")") Or (curChar="[") Or (curChar="]") Then Exit Do
		result = result & curChar
		x = x+1
	Loop
	CropStringAt = result&"..."
End Function


usage:
Code:
Dim mystring
mystring="some long string can come here"
Response.Write(CropStringAt(mystring, 8))

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingCode Bank > Vbscipt/classic ASP - show first x chars and preserve last word


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway