PDA

Click to See Complete Forum and Search --> : 2 textbox questions


Serge
Jan 1st, 2000, 04:58 AM
Check out the RichTextBox control. It can do what you want (concerning colors of your tags). You would have to use SelColor property to assign the desired color.


Public Sub ColorTag(pRich As RichTextBox, pstrTag As String, pColor As Long)
Dim iPos As Integer

iPos = 1
iPos = InStr(iPos, pRich.Text, pstrTag)
Do While iPos
pRich.SelStart = iPos
pRich.SelLength = Len(pstrTag)
pRich.SelColor = pColor
iPos = InStr(iPos + Len(pstrTag), pRich.Text, pstrTag)
Loop
End Sub


Usage: ColorTag RichTextBox, TagToColor, Color
Example: ColorTag RichText1, "<HTML>", vbBlue

You can also use an RGB function gor the color.


For your second question you can do something like this:

Text1.SelText = "MyText"

This will insert the text where the cursor is.

------------------

Serge

Software Developer
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)

Anthrax
Jan 1st, 2000, 11:50 AM
I am creating a web page editor and I would like to make the tags a seperate color from the rest of the text (like the Code windows in VB).

Also... is there a way to input text to a textbox where the curser is instead of the end?

thanks

[This message has been edited by Anthrax (edited 01-01-2000).]

Anthrax
Jan 2nd, 2000, 02:56 AM
Thanks, it worked great, but now I have another problem.

I set the scrollbars on the ritch text box to bolth horizontal and vertical but when text reaches the edge of the box, it starts a new line.