Howto write symbols to a Richtextbox

Posted on 2003-11-23
Last Modified: 2013-12-26
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
Question by:Robsoft
  • 3
  • 3
  • 2
  • +3

Expert Comment

ID: 9806197
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

Author Comment

ID: 9806572
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?

LVL 85

Expert Comment

by:Mike Tomlinson
ID: 9806848
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.

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!


Author Comment

ID: 9806903
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?
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 9807413
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.


Expert Comment

ID: 9807706
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):
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 9808077
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.


Accepted Solution

wsteegmans earned 500 total points
ID: 9810744
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


Author Comment

ID: 9811880
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

Expert Comment

ID: 10074262
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 @
LVL 13

Expert Comment

ID: 11750258
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.


Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question