Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

how to concat with multiple dots..

Posted on 2009-05-08
3
Medium Priority
?
190 Views
Last Modified: 2013-11-07
i have a field testimonial in database, need to concat the total characters to some extent and then it should displays with ...(multiple dots)

Like this
Testimonial(in db )
Testimonials are in the form of letters and ad copy featured very commonly in the advertising of patent medicines in the 19th and 20th centuries. The pages of almanacs and other promotional literature filled up with multiple testimonials,some with accompanying photographs, that tell of the healing powers of the products in question. Dr. R. V. Pierce, marketer of Pierce's Golden Medical Discovery, published

page should be displayed in this format....

Testimonials are in the form of letters and ad copy featured
 very commonly in the advertising........


While (dr.Read())
              <span><%=dr.Item("testimonial")%></span>

Open in new window

0
Comment
Question by:Rajar Ahmed
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 10

Accepted Solution

by:
JPJ78 earned 2000 total points
ID: 24335374
A function like this should do it.
This function cuts the string at a given amount of characters.
The function searches for the closest " ", "?", "!", ".", "," to avoid cutting in the midle of a word.


    Protected Function CutString(ByVal str As String, ByVal maxLength As Integer) As String
        If Not String.IsNullOrEmpty(str) Then
            If str.Length > maxLength Then
                Dim tempStr As String = str.Substring(0, maxLength)
                Dim breakIndex As Integer = 0
 
                Dim index As Integer = tempStr.LastIndexOf(" ")
                If index > breakIndex AndAlso index < maxLength - 3 Then breakIndex = index
 
                index = tempStr.LastIndexOf(".")
                If index > breakIndex AndAlso index < maxLength - 3 Then breakIndex = index
 
                index = tempStr.LastIndexOf(",")
                If index > breakIndex AndAlso index < maxLength - 3 Then breakIndex = index
 
                index = tempStr.LastIndexOf("!")
                If index > breakIndex AndAlso index < maxLength - 3 Then breakIndex = index
 
                index = tempStr.LastIndexOf("?")
                If index > breakIndex AndAlso index < maxLength - 3 Then breakIndex = index
 
                If breakIndex = 0 Then breakIndex = maxLength - 3
 
                Return str.Substring(0, breakIndex) + "..."
            Else
                Return str
            End If
        End If
 
        Return ""
    End Function
 
 
While (dr.Read())
              <span><%= CutString(dr.Item("testimonial"), 80)%></span>

Open in new window

0
 
LVL 18

Author Closing Comment

by:Rajar Ahmed
ID: 31579389
Thanks for a nice and clean functions...
0
 
LVL 18

Author Comment

by:Rajar Ahmed
ID: 24335600
thx<input id="gwProxy" type="hidden"><!--Session data--><input onclick="jsCall();" id="jsProxy" type="hidden">
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question