Link to home
Start Free TrialLog in
Avatar of fskilnik
fskilnikFlag for Brazil

asked on

Is there any special tags and/or codes to apply font effects (e.g. bold) to some words in a texbox text in VB6?

The question is the following:
I have a proprietary application with a special command that can identify some words in a textbox.text in a VB6 application, and more, it is possible to define initial, and end tags, to apply effects to those words (not whole text), like highlighting, bold, italic, etc.

The command is like this: textbox.text = date_base_name.fieldbyname("field_name").HightLightString(index as long, start_tag as string, end_tag as string)

The index value is not applyiable in this case, and the start tag and end tag should be som special code, or codes, to define font effects, like bold.

Is there any tags or codes that can be recognized by VB6 textbox that could be used?
Avatar of kbirecki
kbirecki
Flag of United States of America image

VB6 text box contents are not rich text capable.  You'd have to have some kind of ActiveX control or web browser control that is rich text capable.

If you're trying to set properties of the text box in a design environment, then you need to access the properties of the control, not the contents of the textbox.
Avatar of fskilnik

ASKER

Kbirecki,

I know that exist richtextbox in VB6, different from a simple textbox. I'm trying to use that richtextbox.text instead. Even in this case shoul not be possible to exist a solution?
Thanks!
OK, sure, if you have a RichTextBox control, but I'm not aware of one in VB6 other than third party ActiveX components.  Is that what you have?
OK, I guess there was one.  I never used it.  I'll look to see if I have it available and try to see if I can apply formatting, although I don't have your proprietary app, of course.  Are you just trying to apply rich text formatting and it's failing?
Even you not having the app, this should work like this:

"this is an example of starttagboldendtag word"

I found out some bbcode? Do you know it? www.bbcode.org.
ASKER CERTIFIED SOLUTION
Avatar of kbirecki
kbirecki
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Opps, I see my post applied the bbcode, but I think you knwo what I meant, bbcode uses [ b ] word [ / b ] to format a word as bold where rich text uses less than/greater than symbols.  (no spaces in the bbcode, of course.)
Ok, I understood. I'll try to test your solution, give me some time. Thanks!!!
Avatar of Brook Braswell
in your text "this is an example of word"
to bold the text from your code:
rchText.selStart = 12
rchText.SelLength = 7
rchText.SelBold = true
rchText.selLength = 0

this will bold the word example

if you wish your data saved in rich format then use the rchText.textRTF rather than rchText.Text

this of course would not save just the text but the rich format in your database that you would then have to convert if using in a report unless you use a RichText field on your report.
Brook1966,

I'll test this too. Thanks a lot!!
Just to inform. I need some time more to test because I've had two meetings yesterday....  Tks all.
I am working on this, maybe I need more two days. But I feel that the Kbirecki's suggestion will fit better, even more complex.