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.
Rich Text Box Controls
Inserting text
You might also like...
About the author
ZERO-COOL
I'm a 12 year old child who is interested in learning programming languages. My current two are Visual Basic and C++.
Interested in writing for us? Find out more.
VB 6 books
-
Programming with Microsoft Visual Basic 2008
Programming with Microsoft Visual Basic 2008, Fourth Edition by the best-selling author, Diane Zak, is designed for a first course in programming. Using the most recent version of the software, Visual Basic 2008, this book teaches individuals how to ...
VB 6 forum discussion
-
CorelDRAW VBA: cdrTraceLineDrawing FAILS, producing single linear path instead of Centerline trace?
by dancemanj (0 replies)
-
client/server application using activex
by beautifulheart (0 replies)
-
System Error &H8007007E. The specifed module could not be found.
by swiftsafe (5 replies)
-
Invitation to take part in an academic research study
by researchlab (0 replies)
-
Send SMS with SMPP
by mmahmoud (0 replies)
VB 6 podcasts
-
Stack Overflow Podcast: Podcast #45 – Keeping it Sharp
Published 7 years ago, running time 0h54m
Our guest this week is Eric Lippert – language architect extraordinaire and famous for all his work at Microsoft in developing their languages Eric joined Microsoft right out of college and was originally working on VB It’s time for everyone’s favorite game: Name the Worst Feature of that Microso.
Comments