Is there a better way of showing first * character

Results 1 to 6 of 6

Thread: Is there a better way of showing first * character

  1. #1
    Rai Guest

    Default Is there a better way of showing first * character

    When drawing text from the database, I found out how to show for example only the first 30 characters:<BR><BR>Left(StringToPullFrom,NumOfChar sToPull)<BR><BR>But how can I make sure that only whole words are shown, I think it looks a bit weird when the ends with an uncomplete word... It would be best to still count characters, but remove the last characters if they are not the complete word. Thankful for any help!

  2. #2
    Join Date
    Dec 1969

    Default RE: Is there a better way of showing first * chara

    I have JScript source. hang on.<BR><BR>function splitText(strText) { // returns an array<BR> var intBlockSize = strText.length/3; // 400 characters or thereabouts<BR> var arrReturn = new Array(); var x = 0; var y = 0; var intPlace = intBlockSize;<BR> while(intPlace&#060;strText.length+intBlockSize) {<BR> while(strText.charAt(intPlace)!=&#039; &#039;&&intPlace&#060;strText.length) {<BR> intPlace++;<BR> }<BR> arrReturn[y] = strText.substring(x, intPlace);<BR> x = new Number(intPlace); // by value, not reference<BR> intPlace+=intBlockSize; y++;<BR> } return arrReturn;<BR>}<BR><BR>I&#039;m NOT translating it for you though. I can&#039;t stand VBScript<BR><BR>this version splits in 3 columns - to return first few you&#039;ll need to adapt it a little - should be easy<BR><BR><BR><BR>j

  3. #3
    Rai Guest

    Default Can somebody else translate it into VBscript?

    Thank you but I didnt understand how to translate that

  4. #4
    Eddie Campbell Guest

    Default This is *MUCH* shorter

    mystr="the quick brown fox jumps over the lazy dog"<BR>MyStr = Left(MyStr,InstrRev(Left(mystr,30)," "))<BR>Response.Write MyStr<BR><BR>I know Vbscript may not be as flexible, but this is nice and short.

  5. #5
    Rai Guest

    Default Thank you very much, what does InstrRev mean?


  6. #6
    Eddie Campbell Guest

    Default Search backwards ...

    See the VbScript help on InstrRev at this page :<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