|
-
Jul 15th, 2001, 02:10 PM
#1
Thread Starter
New Member
Replacing Characters With......?
Hi,
Would someone help me on this?
I want to type an:
"A" and printed as "A" on RichTextBox
"B" and printed as "B" on RichTextBox where I have characters "AB".(This part is very easy for me!)
But If I type:
"B" and printed as "B" on RichTextBox
"A" and printed as "A" on RichTextBox where I Should have characters "BA". But I do not want "BA" there. I want "BA" replaced by a character "C". (This part is very very hard for me!)
I really appreciate any kind of feed back on this.
Thanx
nagu
Ps: Please pay attention to sequences
-
Jul 15th, 2001, 03:23 PM
#2
Try this:
VB Code:
Private RichTextBox1_Change()
With RichTextBox1
If InStr(1, .Text, "BA") Then .Text = Replace(.Text, "BA", "C")
End With
End Sub
-
Jul 15th, 2001, 05:58 PM
#3
You don't need to search for the string. Replace() will do it automatically. This method will also preserve the SelStart position.
VB Code:
Private Sub RichTextBox1_Change()
lStart = RichTextBox1.SelStart
RichTextBox1.Text = Replace(RichTextBox1.Text, "BA", "C")
RichTextBox1.SelStart = lStart
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|