Results 1 to 2 of 2

Thread: only Last 2 Chr in RTBox

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2001
    Location
    Caanaaadaaaaaaa
    Posts
    7

    Cool only Last 2 Chr in RTBox

    Hi,
    This is my previous post:


    {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".
    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" OR somethings else.
    I really appreciate any kind of feed back on this.
    Thans
    nagu }

    and Megatron send this code:
    __________________
    Megatron

    Private Sub RichTextBox1_Change()
    lStart = RichTextBox1.SelStart
    RichTextBox1.Text = Replace(RichTextBox1.Text, "BA", "C")
    RichTextBox1.SelStart = lStart
    End Sub
    --------------------------------------------------------------------------------

    This code is working but there is little problem. When I type faster the characters which already been typed go ON and OFF like flasing at very high frequency. I could not see what am I typing unless I slow or stop. I think that for every keypress it scans from the beginig of the RichTextBox.
    Is there any way we can fix this by limiting to last two chrs are being typed and scanned/Replaced, and so on?

    I thank Megatron, Matthew Gates and Zer0 Flaw replying for my previouse post.
    I am looking @ the screen!
    Thanks Everyone
    Nagu '

  2. #2
    Addicted Member VB6Coder's Avatar
    Join Date
    Apr 2001
    Location
    Northampton, UK
    Posts
    185
    You could try this


    If Len(RichTextBox1.Text) > 1 Then

    lStart = RichTextBox1.SelStart
    RichText1.Text = Left$(RichText1.Text, Len(RichText1.Text) - 2) & Replace(Right$(RichText1.Text, 2), "BA", "C")
    RichTextBox1.SelStart = lStart

    End If


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width