Carriage Return converted into symbol ( Vertical Tab, male symbol, symbol for Mars ) by PowerPoint Text shape Object in VB.net - vb.net

I have assigned string having carriage return to PowerPoint shape's texframe text but when I get from it. the carriage return is now Ascii 11 VT. I have searched google but I didn't find any solution exception to use linefeed but that does not work in other scenario.
Here is Code
_answerText = "Yes" + Chr(CharCode:=13) + "No"
powerPointShapeObject.TextFrame.TextRange.Text = _answerText
Could some one please help me to understand why it happen. Thanks in Advance

PowerPoint uses different characters for line endings depending on PPT version and on whether the text is part of a slide title or any other text on a slide.
This page on my PPTFAQ site explains in more detail:
Paragraph endings and line breaks
http://www.pptfaq.com/FAQ00992_Paragraph_endings_and_line_breaks.htm

Try this instead:
_answerText = "Yes" & "\r" & "No"
powerPointShapeObject.TextFrame.TextRange.Text = _answerText

Related

How to prevent line feeds (vbLf) and carriage returns (vbCr) in text boxes in a vb.net text file?

How to prevent line feeds (vbLf) and carriage returns (vbCr) in a text box that should only be one line, in a text file? It can happen that these carriage return characters and these new line characters are present (for example during a copy and paste) in the body of the text and thus make the reading of the file impossible. This has happened to me before, and I think I need to set up a check for the presence of these characters and thus warn the user to check his line before any recording. Thank you in advance. Claude.
Replace the CR and LF with nothing?
textBoxWithCrLf.Text.Replace(vbCr, "").Replace(vbLf, "")
Note, this doesn't modify the contents of the textbox, it generates a new string with no CRLF, so you'd use it like:
somefilewriter.SomeWriteStringMethod( textBoxWithCrLf.Text.Replace(vbCr, "").Replace(vbLf, "") )

VB.NET - Appending text to the last line of text file leaves (sometimes) an empty line

The intention of the software I am coding is to append a string to the last line of a text file. The problem I am experiencing is that depending on the situation, sometimes I get an empty line when I try to append text to the last line of a text file.
My text file is very simple. It contains a few lines of text and each line contains a few words. When I open the text file with Windows' Notepad (without editing the content of the text file) and I move the caret to the end of the entire file, sometimes the caret is positioned at the end of the last line with content (text), and sometimes it is positioned at an empty line that doesn't contain even a white space.
When the caret's ending position corresponds to the last char of a line that contains text, I don't experience any problem appending some text programmatically. The programmatically appended line is at a new line and there isn't any empty line between the old last line and the current last line in the text file.
The problem appears when I can move the caret in the text file to the last possible position and that position corresponds to an empty line. In that case, when I try to append a new line programmatically, I can see an empty line before the just added line.
I have tried different codes and techniques, but it always happens the same to me.
The code I am actually using is:
If stringLastLine.Length = 0 Then
Using sw As StreamWriter = New System.IO.StreamWriter(filePath, True)
sw.Write("Inserted text")
sw.Close()
End Using
ElseIf stringLastLine.Length > 0 Then
Using sw As StreamWriter = New System.IO.StreamWriter(filePath, True)
sw.Write(Environment.NewLine & "Inserted text")
sw.Close()
End Using
End If
Basically, I am trying to detect if the last line length is over zero, so it's a line with text content and I will use "environment.newline + string". If it's a line without content (length = 0) I add directly the string without using "environment.newline". In the case that length = 0 I always get an empty line in between.
Any idea to solve this problem?
How about trimming your text to ensure there's no end of line characters at the end (the whole text)? Right now you might have an issue with multiple blank lines:
text = text.TrimEnd({Convert.ToChar(10), Convert.ToChar(13)})
This handles the EOL characters.

Replace a 'bel' character in a file in vb.NET

I've come across a character in one of my data feeds, which I have never encountered before
The images above are the data feed in Notepad++ and Notepad view. As you can see it appears as 'BEL' in Notepad++ and a sort of 'bullet point' in Notepad.
How would I go about replacing this character in vb.NET?
I've tried a simple replace in a SSIS Script Task by copying and pasting the character into the replace function, e.g.
text = text.Replace("copy and pasted character", "")
and this gives this error
All help is extremely appreciated,
Thanks
I’ve got no idea what SSIS is but since you wanted to know a solution in VB.NET, the code you’ve tried will work here. That is:
text = text.Replace("copy and pasted character", "")
will work just fine in VB. Alternatively, you can use the following:
text = text.Replace(Chr(7).ToString(), "")
Find out what the Ascii value of the character is and then use the Chr function to eliminate it
i.e.
text = text.Replace(Chr(n), "")
[Bell] is probably character 7

How do I remove the box symbol that shows up for a line break when I output a string to a cell?

I have a userform where the user enters a description of their project into a textbox and it is stored in a string. When the user runs the "Generate Report" routine that string is output to a single cell. If the user entered line breaks, they are present in the output, but there is also a "box" character for each line break. I can manually delete the "box" character and the line break is still there in the cell, but how do I prevent the "box" character from showing up in the first place?
Your string is probably carrying a vbCrLf (Carriage Return + Line Feed). All you need to do is remove the CR of the CR+LF.
Try this:
(YourCell.Value Here) = Replace(YourString, vbCrLf, vbLf)
Good luck.

Formatting text from Mulitline text box in word with VBA

I'm putting together a template in Word, using a form for the user to fill in to then populate some of the document.
The bit I'm currently stuck on is at the end of the document, where the cc's are listed.
The form has a multiline text box into which the user puts in their cc's, one per line.
I then want to add to the end of the document the contents of the text box, but in the right format. Specifically, it should look like:
cc: First CC contact
Second CC contact
so on and so forth
I attempted to do this using 2 bookmarks, so my code currently is:
' If 'CC' box has content, add it
If doc_CC.TextLength > 0 Then
.Bookmarks("CC").Range.Text = vbCr + "cc:"
.Bookmarks("CCs").Range.Paragraphs.Indent
.Bookmarks("CCs").Range.Text = doc_CC + vbCr
End If
However, when this is run, on the page it looks like:
cc: first contact
second contact
and so on
Realise that the 2 bookmark method is a bit messy but it seemed like a good idea at the time - obviously this is not the case! Have done some searching for a way to do it with Split but am not making much progress down this path - suspect I'm googling for the wrong thing.
How do I do this so that the formatting is as desired? Any help is greatly appreciated.
Try inserting a tab character? + Chr(9) or even + vbTab may work.
Have found a work around which, while doesn't answer the actual question of how to do it, does produce a result to the same effect.
Have used a 2 column table without no lines instead with contents of a1 being "cc:" and contents of a2 being whatever was entered into the multiline text box. If there is nothing in the text box, then the table is deleted.
I'll keep on eye on this question though so if some one does have the proper answer I can mark it accordingly.
Another possibility would be to format the cc paragraph with a hanging indent (like is used for bullets or numbering). Use a newline character - Chr(11) - instead of vbcr to separate each entry. The text should all line up,then...