Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Rated
Read 103,029 times

Contents

Related Categories

Rich Text Box Controls - Inserting text

ZERO-COOL

Inserting text

Inserting text with the rich textbox control is made very simple.  It has three parts: SelStart, SelLenth, and SelText.  The SelStart is where the text is going to be inserted (in letters), and can't be longer than the the text.  SelLength is the total number of letter that will be deleted after SelStart.  SelText is the text that is going to replace the SelLength.  If SelLength is zero the SelText will just be inserted where SelStart is.

Object.SelStart = Integer
Object.SelLenth = Integer
Object.SelText = Text

'RichTextBox1 displays "Good "
RichTextBox1.SelStart = 5
RichTextBox1.SelText = "Evening"
'RichTextBox1 now displays "Good Evening

If you want to replace text I suggest you do the Replace function.  The following is how to make a replace function.

Object = Replace(String, Find, ReplaceWith, _
Start, NumerToCorrect)

Dim Temp As String
'I prefure to use a variable
Temp = RichTextBox1.Text
'RichTextBox1 displays "aaAaAAaa"
Temp = Replace(Temp, "a", "B", 2, 3)
RichTextBox1.Text = Temp
'RichTextBox1 now displays "aBABAABa"

It replaced 3 "a" with "B" starting from the second letter of Temp and then set the text back to Temp.  That is how the replace function works.  You can skip the number of times to replace, and it will replace every existence after the start.  If you skip the start, it will start searching from the beginning.

I'm a 12 year old child who is interested in learning programming languages. My current two are Visual Basic and C++.

Comments

  • hi

    Posted by kailas on 17 Oct 2005

    hi redstar...

    m also facing same problem.. do u got any solution?

    with regards,

    kailas

  • arrow intendation

    Posted by sshamsudheen on 21 Apr 2005

    how to get arrow intendation

  • bullet intending

    Posted by sshamsudheen on 21 Apr 2005

    how to chane the bullet intend as arrow

  • Saving and Loading Text formats

    Posted by DanTheMan on 03 Feb 2005

    I am wondering if thier is a way to save and load text formatting using VB6, for example fonts, text colors etc. Does anybody know any easy ways round it???

  • a work around

    Posted by ulaska on 26 Aug 2003

    Try the following code as work around:

    ' flag the section with bullet mark
    rtfSectionText.SelBullet = True

    ' replace bullet with numbers
    rtfSectionText.SelRTF = Replace(rtfSectionText.SelRTF, ...