SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2005
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help formatting a string of text

    How to I format the following string from

    The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.

    to

    The quick brown fox jumps over the lazy dog. The quick brown fox jumps
    over the lazy dog. The quick brown fox jumps over the lazy dog. The quick
    brown fox jumps over the lazy dog.


    so it looks nice and neat and does not scroll off the edge if the ASP.NET (VB) page?
    Last edited by kg1; Jan 9, 2007 at 19:57.

  2. #2
    SitePoint Enthusiast
    Join Date
    Dec 2005
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Please, somebody help. I have tried setting the table and row width, I've tried using CSS. Nothing seems to work

  3. #3
    SitePoint Enthusiast
    Join Date
    Dec 2005
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <%
            
    Dim myString As String "I was walking through the park when I realised I was insane. 'oh my goodness', i said out loud."

            
    Dim myNewString As New StringBuilder(myString)
            
    Dim position As Integer 33
            Dim timesToLoop 
    As Integer Round(myString.Length position0)
            
    Dim val As String
     
            
    For counter As Integer 0 To timesToLoop 1
                
    Do While Not position myString.Length
                    val 
    myNewString(position)
                    If 
    val " " Then
                        myNewString
    .Insert(position"<br />")
                        
    position += 33
                        
    Exit Do
                    
    End If
                    
    position += 1
                Loop
            Next
            
            Response
    .Write(myNewString)
    %> 
    It works, yippee

  4. #4
    SitePoint Enthusiast
    Join Date
    Dec 2005
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's another function

    PHP Code:
    Public Function WordWrap(ByVal strTextToBeWrapped As StringByVal intMaxLineLength As Integer) As String
            Dim wrappedText 
    As String
            Dim lengthOfInput 
    As Integer
            Dim currentPosition 
    As Integer
            Dim currentLineStart 
    As Integer
            Dim positionOfLastSpace 
    As Integer

            lengthOfInput 
    Len(strTextToBeWrapped)
            
    currentPosition 1
            currentLineStart 
    1

            
    Do While currentPosition lengthOfInput
                
    If Mid(strTextToBeWrappedcurrentPosition1) = " " Then
                    positionOfLastSpace 
    currentPosition
                End 
    If

                If 
    currentPosition currentLineStart intMaxLineLength Then
                    wrappedText 
    wrappedText Trim(Mid(strTextToBeWrappedcurrentLineStartpositionOfLastSpace currentLineStart 1)) & vbCrLf
                    currentLineStart 
    positionOfLastSpace 1
                    
    Do While Mid(strTextToBeWrappedcurrentLineStart1) = " "
                        
    currentLineStart currentLineStart 1
                    Loop
                End 
    If

                
    currentPosition currentPosition 1
            Loop

            wrappedText 
    wrappedText Trim(Mid(strTextToBeWrappedcurrentLineStart)) & vbCrLf
            wrappedText 
    Replace(wrappedTextvbCrLf"<br />" vbCrLf)

            Return 
    wrappedText
    End 
    Function 


Bookmarks

Posting Permissions

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