This shouldn’t be all that hard, but i’ve spent much of the afternoon on what should be something very simple: removing the trailing and leading carriage returns from a single text string.
given something like:
"text here
"
I’ve tried trim, trim$ full trim, converting my string to a Cstr, i even tried Replace with a Chr(10). Nothing worked, it always returns the extra lines
Sub Click(Source As Button)
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim update As String
Set uidoc = workspace.CurrentDocument
update= uidoc.FieldGetText( "NewUpdate" )
'update = Replace(update, "", "____")
'update = Fulltrim(Cstr(update))
update = Trim(Cstr(update))
update = Trim$(Cstr(update))
Messagebox "The Update is:" &Chr(10)& Trim(update)
Messagebox "The Update is:" &Chr(10)& Trim$(update)
Messagebox "The Update is:" &Chr(10)& Fulltrim(update)
End Sub
Subject: Way to remove blank lines from a single string?
You can try this.
Public Function ReplaceSubstring(Source As String, Find As String, ReplaceStr As String ) As String
Dim findLen As Long
Dim replaceLen As Long
Dim index As Long
Dim counter As Long
findLen = Len(Find)
replaceLen = Len(ReplaceStr)
If findLen > 0 Then
index = 1
ReplaceSubstring = Source
Do
index = Instr(index, ReplaceSubstring, Find, 5)
If index = 0 Then Exit Do
If findLen = replaceLen Then
Mid$(ReplaceSubstring, index, findLen) = ReplaceStr
Else
ReplaceSubstring = Left$(ReplaceSubstring, index - 1) & ReplaceStr & Mid$(ReplaceSubstring, index + findLen)
End If
index = index + replaceLen
counter = counter + 1
Loop
If Start > 1 Then ReplaceSubstring = Mid$(ReplaceSubstring, Start)
Else
ReplaceSubstring = Source
End If
End Function
Function ClearString(Source As String) As String
ClearString = Source
ClearString = ReplaceSubString( ClearString, Chr(13), "" )
ClearString = ReplaceSubString( ClearString, Chr(10), "" )
End Function
Subject: I think the Chr(13) did the trick
I was using Chr(10)
update = Replace(update, Chr(13), “”)
update = Fulltrim(update)
It seems i still need both statements, though i;m not quite sure why, either way it looks like it’s good enough!
Thanks!
Subject: *Internally, Notes stores carriage returns as Chr(0), not Chr(13) or Chr(10)
Subject: *Internally, Notes stores carriage returns …
But for the code actually running in the client, isn’t it still the platform’s convention, that has to be obeyed, not the internal storage format?
This works (without the need for a further fulltrim)
update = Replace(update, Split(Chr(13) & “,” & Chr(10), “,”), “”)
but this does not
update = Replace(update, Chr(0), “”)