Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Highlighting characters in VB6 Textbox while typing itself....

Hi Genius
VB6 Form has 1 Textbox
if I type "abc" (without Quotes) in the Texbox
the whole word "abc" (without Quotes) should be
highlighted & focus should be in Textbox itself.

Comments

  • BitByBit_ThorBitByBit_Thor Posts: 2,444Member
    : Hi Genius
    : VB6 Form has 1 Textbox
    : if I type "abc" (without Quotes) in the Texbox
    : the whole word "abc" (without Quotes) should be
    : highlighted & focus should be in Textbox itself.
    :
    :

    As in:

    [code]
    Textbox Type char
    a
    [color=blue]a[/color] b
    [color=Blue]ab[/color] c
    [/code]
    Where the left column in how the textbox looks before typing the character in the right column.
    So, as you type the character gets added to the selected part. Is that what you want?

    It would involve capturing a couple of events from the textbox that would normally do something to the selected index. Also, when the user types c and ab are selected, then normally ab will be deleted. This you're going to have to handle as well in the keypress event.

    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
  • rajeshnrh74rajeshnrh74 Posts: 3Member
    Thnks for your response.
    Actually my work behind reading Barcode thru Barcode Reader into the
    TextBox, The Maxlength of the TextBox is 12.
    If I Input some characters manually into the TextBox Say "abc" (without quotes)
    now the cursor is in 4th place from there it won't allow Barcode Reader to read.
    It should start from 1st place only by erasing already existing 3 characters.
    This is my situation.

    Can U come out of this.

  • BitByBit_ThorBitByBit_Thor Posts: 2,444Member
    : Thnks for your response.
    : Actually my work behind reading Barcode thru Barcode Reader into the
    : TextBox, The Maxlength of the TextBox is 12.
    : If I Input some characters manually into the TextBox Say "abc"
    : (without quotes)
    : now the cursor is in 4th place from there it won't allow Barcode
    : Reader to read.
    : It should start from 1st place only by erasing already existing 3
    : characters.
    : This is my situation.
    :
    : Can U come out of this.
    :
    :

    I am not sure about how a barcode reader works... How does it input the characters? The solution to your problem probably can be handled by intercepting the Textbox Changed event, and setting the selected text to the entire contents of the textbox.

    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
  • lionblionb Posts: 1,688Member ✭✭
    : : Thnks for your response.
    : : Actually my work behind reading Barcode thru Barcode Reader into the
    : : TextBox, The Maxlength of the TextBox is 12.
    : : If I Input some characters manually into the TextBox Say "abc"
    : : (without quotes)
    : : now the cursor is in 4th place from there it won't allow Barcode
    : : Reader to read.
    : : It should start from 1st place only by erasing already existing 3
    : : characters.
    : : This is my situation.
    : :
    : : Can U come out of this.
    : :
    : :
    :
    : I am not sure about how a barcode reader works... How does it input
    : the characters? The solution to your problem probably can be handled
    : by intercepting the Textbox Changed event, and setting the selected
    : text to the entire contents of the textbox.
    :
    : Best Regards,
    : Richard
    :
    : The way I see it... Well, it's all pretty blurry
    :
    I do not know how BarCode Reader works too. May be that's why I have following questions:

    1. Why do you need to highlight text in Text box before clear it?
    2. Why do you need to wait for 4th(any number) character to be typed/entered before to start clear text box?
    3. Why you don't place code like that
    [code]
    txtMyText.Text = ""
    [color=Green]'or[/color]
    txtMyText.Text =vbNullString
    [/code]
    to clear text box in BarCode Reader event or before it starts to work?

    Anyway there is a code example how to highligt text and clear text box
    [code]
    Private Sub Text1_Change()
    If Len(Text1.Text) = 4 Then
    Text1.SelStart = 0 [color=Green]' highligt text[/color]
    Text1.SelLength = 3 [color=Green]' highligt text[/color]
    Text1.Text = vbNullString [color=Green]' clear text box [/color]
    Text1.SetFocus
    Exit Sub
    End If

    End Sub
    [/code]
Sign In or Register to comment.