String Manipulation Help

Results 1 to 2 of 2

Thread: String Manipulation Help

  1. #1
    Saam Tariverdi Guest

    Default String Manipulation Help

    Hello,<BR><BR>Here is my situation: Let&#039s say I get a "News Headline" field from my database, and it is 40 characters long. I want it so that if the length is greater than 25 chars long, I want it to print out the first 22 chars, followed by "..." (without quotes). For example:<BR><BR>Headline1 = "Hello, this is a test test tes" (31 chars)<BR>Therefore, it should display: "Hello, this is a test tes..."<BR><BR>Headline2 = "Good Morning!"<BR>Therefore, it should display: "Good Morning!"<BR><BR>How would I go about coding this algorithm? Thanks in advance.

  2. #2
    Ugh!! Guest

    Default RE: String Manipulation Help

    Here you go:<BR><BR>&#060;%<BR>Const iMaxLen = 25<BR><BR>&#039 Test Data<BR>Dim sX<BR>sX = "Hello this is a test which is longer than 25 chars"<BR>&#039sX = "Shorty"<BR><BR>If Len(sX) &#062; iMaxLen then<BR> Response.Write Left(sX,iMaxLen-3) & "..."<BR>Else<BR> Response.Write sX<BR>End If<BR><BR>%&#062;<BR><BR>Where iMaxLen is the maximum length you want to display.<BR><BR>Enjoy<BR><BR>Ugh!!<BR>----------------------------<BR><BR>----------------------------<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts