ChopLastWord Function
page 2 of 3
by Topher Jentoft
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 15164/ 116
Article Contents:

Code

Below is the function that is used to accomplish this task:

' Copyrights (c) 2000, Martin Jansen
' This function chops the last word of a given string.
Function ChopLastWord( Line, Length )
 Dim S1, S2, I
 ChopLastWord = ""
 S1 = Left( Line, Length )
 S2 = Left( Line, Length )
 For I = Len(S1) to 1 step -1
  if Mid(S1,I,1) = " " then
   S2 = Left(S1,I)
   I = 0
  end if
 Next
 ChopLastWord = S2
End Function  
 

This function is used just like Left(), taking an input string and a length. The length is the maximum length that the result can be, but typically the result will be LESS than this length because it will chop off entire words until the full string is less than the provided length.


View Entire Article

Article Feedback

Title:  
Name:  
Url: ( Optional )
Comment:  
Please add 2 and 2 and type the answer here:

User Comments

Title: Bothe Great Solutions   
Name: David Johndrow
Date: 2/2/2007 12:15:59 PM
Comment:
Thanks, very fast and easy to implement.
Title: satish   
Name: satish
Date: 5/21/2005 2:29:04 AM
Comment:
thank you
Title: ChopLastWord Function   
Name: ChopLastWord Function
Date: 7/9/2004 7:32:41 PM
Comment:
Thank you so much for this!

Product Spotlight
Product Spotlight 
Learn More
.NET Tools
asp.net shopping cart
asp.net chart control






Ads Powered by Lake Quincy Media
Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2008 ASPAlliance.com  |  Page Processed at 7/5/2008 5:00:31 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search