Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 391741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:05:27+00:00 2026-05-12T16:05:27+00:00

I have a large text field taken from a database rs.Item(content) How can I

  • 0

I have a large text field taken from a database

rs.Item("content")

How can I limit this to say 100 characters but not cut off the last word. eg “limit this to 100 cha…”

Id like to add the… onto the end also.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T16:05:28+00:00Added an answer on May 12, 2026 at 4:05 pm

    I use the following method:

    ''' <summary>
    ''' Creates a shortend version of a string, with optional follow-on characters.
    ''' </summary>
    ''' <param name="stringToShorten">The string you wish to shorten.</param>
    ''' <param name="newLength">
    ''' The new length you want the string to be (nearest whole word).
    ''' </param>
    ''' <param name="isAbsoluteLength">
    ''' If set to <c>true</c> the string will be no longer than <i>newLength</i>.
    ''' and will cut off mid-word.
    ''' </param>
    ''' <param name="stringToAppend">
    ''' What you'd like on the end of the shorter string to indicate truncation.
    ''' </param>
    ''' <returns>The shorter string.</returns>
    Public Shared Function ShortenString(stringToShorten As String, newLength As Integer, isAbsoluteLength As Boolean, stringToAppend As String) As String
      If Not isAbsoluteLength AndAlso (newLength + stringToAppend.Length > stringToShorten.Length) Then
        ' requested length plus append will be longer than original
        Return stringToShorten
      ElseIf isAbsoluteLength AndAlso (newLength - stringToAppend.Length > stringToShorten.Length) Then
        ' requested length minus append will be longer than original
        Return stringToShorten
      Else
        Dim cutOffPoint As Integer
    
        If Not isAbsoluteLength Then
          ' Find the next space after the newLength.
          cutOffPoint = stringToShorten.IndexOf(" ", newLength)
        Else
          ' Just cut the string off at exactly the length required.
          cutOffPoint = newLength - stringToAppend.Length
        End If
    
        If cutOffPoint <= 0 Then
          cutOffPoint = stringToShorten.Length
        End If
    
        Return stringToShorten.Substring(0, cutOffPoint) + stringToAppend
      End If
    End Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a large database on which we have DB side pagination. This is
I have a large text template which needs tokenized sections replaced by other text.
I have a rather large text file that has a bunch of missing newlines,
I have a large amount of text in a UITextView. I want to let
I have to deal with very large text files (2 GBs), it is mandatory
I have a large file in my repository that is not text-mergeable and that
I have several laptops in the field that need to daily get information from
So I have this form that has tons of text boxes, combo boxes, etc.
I have some text displaying in a larger font size than what it is
I have large data sets (10 Hz data, so 864k points per 24 Hours)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.