VB Form field highlighting

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using a VB Form to allow a barcode to be scanned into a text box and
then various other actions take place. This is the only input field on the
screen. All others are display only. The problem I have is that after the
barcode is scanned, the cursor remains at the end of the scanned number. I
would like the whole field to be selected (highlighted) so that I can then
scan another number to overwrite the previous one. One possibility is to make
the cursor tab to another field and then back again but this is outside of my
ability.
I'm using VBA that comes with excel 2003. (6.3)I think
 
Private Sub CommandButton1_Click()
TextBox1.SelStart = 0
TextBox1.SelLength = Len(TextBox1)
TextBox1.SetFocus
End Sub

While I have put this in a commandbutton, it isn't clear how you would need
to trigger it. Surely something happens after the barcode is scanned in or
does someone just look at the userform? (how are other controls populated?)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top