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.