Posted By

ginoplusio on 12/09/08


Tagged

function ASP truncate wordwrap


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

Scooter
benrudolph
AadBr


ASP word wrap function


 / Published in: ASP
 

URL: http://www.barattalo.it/

asp function similar to php one, to truncate long words inside a string

  1. Function wordwrap(str,width,breakString)
  2. Dim words
  3. Dim out, temp
  4. Dim i,k
  5. out = ""
  6. words = Split(str," ")
  7. For i = 0 To UBound(words)
  8. If Len(words(i)) >= width Then
  9. temp = ""
  10. parola = words(i)
  11. For k = 1 To Len(parola)
  12. temp = Left(parola,k)
  13. If len(temp)>=width Then
  14. out = out & temp & breakString
  15. parola = Right(parola,Len(parola) - width)
  16. k = 1
  17. temp = ""
  18. End if
  19. Next
  20. out = out & temp & breakString
  21. Else
  22. out = out & words(i) & breakString
  23. End If
  24. Next
  25. wordwrap = Trim(out)
  26. End Function

Report this snippet  

You need to login to post a comment.