Visual Basic

Moderators: None (Apply to moderate this forum)
Number of threads: 17974
Number of posts: 55343

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Highlighting characters in VB6 Textbox while typing itself.... Posted by rajeshnrh74 on 22 Nov 2007 at 4:28 AM
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.

Report
Re: Highlighting characters in VB6 Textbox while typing itself.... Posted by BitByBit_Thor on 22 Nov 2007 at 5:22 AM
: 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:

Textbox     Type char
            a
a           b
ab          c

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
Report
Re: Highlighting characters in VB6 Textbox while typing itself.... Posted by rajeshnrh74 on 22 Nov 2007 at 2:29 PM
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.

Report
Re: Highlighting characters in VB6 Textbox while typing itself.... Posted by BitByBit_Thor on 23 Nov 2007 at 2:07 AM
: 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
Report
Re: Highlighting characters in VB6 Textbox while typing itself.... Posted by lionb on 26 Nov 2007 at 6:05 AM
: : 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
   txtMyText.Text = ""
   'or
   txtMyText.Text =vbNullString 
   

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
Private Sub Text1_Change()
If Len(Text1.Text) = 4 Then
   Text1.SelStart = 0         ' highligt text
   Text1.SelLength = 3        ' highligt text
   Text1.Text = vbNullString  ' clear text box  
   Text1.SetFocus
   Exit Sub
End If
   
End Sub




 

Recent Jobs