Howto write symbols to a Richtextbox

Hi Experts

I recently had a similar question
regarding write symbols to a word document, but due to compat. and the amount of time it takes to use the automation, I have chosen to use a RTB and saving it as .rtf - but my problem is:
How do I send (write) symbols to a RTB?

I want to use a monospaced font (aka old MS Linedraw) for this I picked Courier New.

I need the special chars to build/draw a box (DOS-like) :  ┌ ┐┬└ ┘┴

Please add a little code-sample.


XP Pro - VB6/SP5 - Office 2000
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

why don't you try the sendkeys
first of all get the ascii of the character you want to send
then use the following

SendKeys Chr(TheAsciiNumber)

There Are 10 Kind OF People
Those Who Understands Binary AND Those Who Don't
RobsoftAuthor Commented:
anaadoul, I'm not trying to send/write to another application - I have RTB (hidden) to which I want to write symbols (Courier New).
I don't think you can use Sendkeys on a control - or am I missing something?

Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
If these, are what you are looking for then you are out of luck.  The Chr() function returns the ANSI extended set, not the ASCII extended set.  Typically, this is what you get when you pass 128 - 250 to chr() for most fonts in windows.

If you want the old dos characters, you have to find a font that specifically has the characters in it.

Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

RobsoftAuthor Commented:
Yes, thats true Idle_Mind, that's why I am seeking a way to get the same functionality when
writing to a Richtextbox (where you can set the font!) as when I'm writing to a Word doc. (automation):

Selection.InsertSymbol Font:="Courier New", CharacterNumber:=9484, Unicode _

What or how should the above statement be changed to get the character to a Richtextbox?
Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
As far as I know, there is no equivalent function in VB.  The InsertSymbol() function can only be used within Office Applications.

I suppose if you wanted to get tricky enough you could create a word document, insert the symbol, cut it the clipboard, and then paste it into your RichTextBox, but that's basically where you were already.

Did you already tried the wide AscW and ChrW$ (in VB, VBA and VB.Net)? You just have to use it like that:
ChrW$(9484) and it returns the character you want: ┌

Everything about VB-strings (and optimizing strings):

Some general info about using UNICODE in VB (with also API-Solutions):
Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
Not much out there on this subject.  I don't have any personal experience with unicode but from what I can see you need to do three things:

1) Have language support installed on your computer

2) Use the MS Forms 2.0 Controls

3) Use the ChrW() function instead of Chr().

These links may be of interest to you.

Tested it yesterday with VB.Net ... In VB.Net the RTB can handle UNICODE ...

However, VB6 and most OCX really don't use Unicode. Though VB uses Unicode internally, but all strings are converted to single byte characters, when passed to external subroutines. Most standard controls also don't use Unicode to store and display any text.

Considering the fact that Forms 2.0 is a dead technology and there isn't a Rich Text Box in it (and it's not allowed to distribute it with your program), you can look for an alternative RTB ActiveX, but I couldn't find any interesting, or you must stay using the ANSCI/ASCII set :-(

Funny thing is: When you copy/paste (Ctrl+C/Ctrl+V) these characters from your Word Document to your Richt Text Box, then it works ... What happens, to copy content from a RT App (Word) to the RTB-Control, the data in the ClipBoard is probably stored in Rich Text Format.

For example, copy/paste one of your characters and then watch the property TextRTF of your RTB, you will get something like this:
{\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fswiss\fprq2\fcharset0 Arial;}{\f1\fnil\fcharset0 Futura Lt BT;}}
\par }

When you do it in the other way. Set the TextRTF-Propery of an empty RTB-Control to this
{\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fswiss\fprq2\fcharset0 Arial;}{\f1\fnil\fcharset0 Futura Lt BT;}}
\par }

You first sign will show up. You also see the UNICODE-value in this fragment (u9484) So, I guess you have to use the real RTF-code to create these characters in your RTB-Control, because UNICODE can't be used directly ...

The Richt Text Format (RTF) Specification


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RobsoftAuthor Commented:
Hi guys

Thank's for your comments, I have accepted wsteegmans answer.

Seems I'm out of luck here.
I still have to decide how to deal with it, either RTF codes, some ActiveX or
stick with the solution I have, which I don't like!

VB.Net is a bit in the future for me, too bloated.

Best wishes
Dear Robsoft,

I know this is late but I do have a solution to your problem.  in an RichTextEdit box you can manipulate the text in the box as well as the headers for the rtf file.  You can add MS line drawing characters by concatinating them into the richtext string at the point you want.  For example:  
                    rtfEdit.TextRTF = rtfEdit.TextRTF & "\u9556?"  

adds a drawing character to the end of the text in the text edit box.  You may have to insert it at a specific point which will take some calculation to figure it out.  

For my usage I am building the rtf header manually and then adding one character at a time and then finishing with the rtf footer.  If you have any questions you can email me @
I have similar problem facing in rich text box. I am unable to display greek characters in RTF box. I have a database which stores greek data but when i am setting the text property with rs.fields(0) then it doesn't display properly. Please help me.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.