INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Removing double "newline" strokes from string

Removing double "newline" strokes from string

(OP)
Hi all,

I am having issues properly identifying the end of a string I am parsing into an array because of multiple new line strokes. I am properly identifying it ending on a "space" and not mid word, but because of the Chr$(10) check I have when it hits a double enter it assumes the note has finished.

I figured the easiest way around this is using a custom function ->

CODE -->

Function RemoveChars(strText As String, strUnwanted As String) As String

    Dim TempStr, CurChar As String
    Dim x As Integer
    
    For x = 1 To Len(strText)
        CurChar = Mid(strText, x, 1)
        If InStr(strUnwanted, CurChar) = 0 Then TempStr = TempStr & CurChar
    Next x
    RemoveChars = TempStr
    
End Function 

To remove it, but it appears in the CSV the enter strokes are registered as Chr$10, not Chr$13 for carriage return, so I'm having a brutal time clearing them out. Here's where it's doing the work of storing the lines of the string into an array (no more than 64 chars per entry).

Any help would be super appreciated, it's been bugging me a while.

CODE -->

While GetField(sInput,sNoteArrayCnt+1, Chr$(10)) <> ""
            Redim Preserve sNoteArray(sNoteArrayCnt)
            sNoteArray(sNoteArrayCnt) = GetField$(sInput,sNoteArrayCnt+1, Chr$(10))
            sNoteArrayCnt = sNoteArrayCnt + 1
        Wend
    
        k=0
        ReDim fNoteArray(0)
         
            For i = LBound(sNoteArray) To UBound(sNoteArray)
                arrayItem = sNoteArray(i)
                Do While (Len(arrayItem)>0)
                    temp = Left$(arrayItem,64)
                    If(Trim$(Right$(temp,1)) = "" Or Trim$(Mid$(arrayItem,64,1))="") Then
                        If(k<>0) Then
                            ReDim Preserve fNoteArray(UBound(fNoteArray) + 1)
                        End If 
                        fNoteArray(UBound(fNoteArray)) = RTrim$(temp)
                        arrayItem = Trim$(Mid$(arrayItem, 64))
                        k = k + 1
                    Else
                        trimLength = 0
                        Do While(Mid$(temp,len(temp)-trimlength,1) <> " ")
                            trimLength = trimLength + 1                    
                        Loop

                        temp = Mid$(temp, 1, Len(temp) - trimLength - 1)
                        If (k <> 0) Then
                            ReDim Preserve fNoteArray(UBound(fNoteArray) + 1)
                        End If
                        fNoteArray(UBound(fNoteArray)) = RTrim$(temp)
                        arrayItem = trim$(Mid$(arrayItem, Len(temp)+1))
                        k = k + 1
                    End If
                Loop   
            Next
        
        For x = 0 To UBound(fNoteArray)
             FixedNote = fNoteArray(x)
             FixedNote = RemoveChars(FixedNote, Chr$(9))
             FixedNote = LTRIM(FixedNote)
             Print #2, FixedNote
        Next 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close