ASP word wrap function


/ Published in: ASP
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.