473,383 Members | 1,805 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Barcode Scanner - Textbox - VB.NET

I would like to emulate the afterupdate event in vb.net after scanning
a barcode.

I have multiple barcodes to scan and after each scan I would like focus
to move to the next text box.

I have mainly stuck with the Key press/down/up events. The wedge
scanner is programmed for a 'return' keystroke after a scan. Only the
first char of the barcode is printing in the text box and then the
focus moves to the next text box.
I appreciate any suggestions! Thanks!

Nov 21 '05 #1
4 22710
It sounds like you're using the "ChangedText" event in your program,
which fires after every character is entered.

Assuming that your wedge is a keyboard wedge, you should be able to
check the ProcessCmdKey on the form. You could try a line like
If keyData = Keys.Enter Then SendKeys.Send("{Tab}") : Return True

Now, that being said, I would create a user control based on the text
box that handles the Enter Key as a tab. It's really easy and with just
a few lines of code. The down side is that you have another dll that
you must distribute with your application.

I also like an event that fires if the value of the textbox changes,
instead of firing on every character. I'll throw this code in as well.

I've also included the optional bitmap entry, if you want to use your
own icon instead of the default icon for your control in the IDE,
otherwise; just delete the line with "ToolboxBitmap"

1) Create a user control called anything you want
2) Switch to the code screen in the IDE
3) Change all of the code above the system generated to

Imports System.ComponentModel
Imports System.Text
<ToolboxBitmap(GetType(YourBitMapName))> _
Public Class YourTextBoxName
Inherits TextBox
Private m_EnterValue As String
Public Event ValueChanged(ByVal sender As Object, ByVal e As
System.EventArgs)

.. . .

4) Add code under the system generated code

Protected Overrides Function ProcessCmdKey(ByRef msg As
System.Windows.Forms.Message, ByVal keyData As
System.Windows.Forms.Keys) As Boolean
If keyData = Keys.Enter Then SendKeys.Send("{Tab}"): Return True
End Sub

' Bonus code to see if the value changed
Private Sub YourControlName_Enter(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Enter
m_EnterValue = Me.Text
Exit Sub

Private Sub YourControlName_Leave(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Leave
If m_EnterValue <> Me.Text Then RaiseEvent ValueChanged(sender, e)
Exit Sub

5) Compile the program
6) Add a control under the IDE, Browse to the "bin" directory
containing the dll.
7) Add your new control to your form like any other form.

I've not tested this code, so I may have left something out. I just
pulled a subset of one of my user controls for this reply. Hope it
helps.

More information on creating user controls may be found in the book:
Mastering Visual Basic .NET by Evangelos Petroutsos. The book is pretty
informative, but my binding fell apart after six months! :)

Nov 21 '05 #2
"Shane" <sh********@yahoo.com> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com...

Now, that being said, I would create a user control based on the text
box that handles the Enter Key as a tab. It's really easy and with just
a few lines of code. The down side is that you have another dll that
you must distribute with your application.


Why would you have to have another dll? Why not just include it in the
current project, or am I missing something obvious?

Chris
Nov 21 '05 #3
Hi,
If you set the forms keypreview property to true this will tab to
the next control every time return is "pressed".

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown

If e.KeyCode = Keys.Enter Then

Me.SelectNextControl(Me.ActiveControl, True, True, True, True)

End If

End Sub

Ken

-----------------
<mi*******@yahoo.com> wrote in message
news:11********************@c13g2000cwb.googlegrou ps.com...
I would like to emulate the afterupdate event in vb.net after scanning
a barcode.

I have multiple barcodes to scan and after each scan I would like focus
to move to the next text box.

I have mainly stuck with the Key press/down/up events. The wedge
scanner is programmed for a 'return' keystroke after a scan. Only the
first char of the barcode is printing in the text box and then the
focus moves to the next text box.
I appreciate any suggestions! Thanks!
Nov 21 '05 #4
Thank you so much! This line of code:
If keyData = Keys.Enter Then SendKeys.Send("{Tab}") : Return True
is exactly what I was looking for.
Our IT team is in the early stages of .NET conversion and so keeping it
simple right now is the key.
Thanks again!

Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: CHANGE username to westes | last post by:
What are the most popular, and well supported, libraries of drivers for bar code scanners that include a Visual Basic and C/C++ API? My requirements are: - Must allow an application to be...
2
by: Dean | last post by:
I want to integrate a simple USB POS barcode reader into my VB .NET app. Only need a scan a few products per minute, nothing major. I'm not really sure where to start, is there an SDK I need, does...
8
by: DS | last post by:
Does anyone know anything about barcodes in Access. I don't want to create them in Access. I merely want to scan whats already been created. I need to scan Liquor bottles. I have the scanner...
10
by: Mudasir Ahmed | last post by:
I Guys : I am working on a Application to read barcodes from a scanner and list them in a ListBox on a web page. I was wondering if any one has done a similar job. Currently I have attached the...
6
by: Samuel Shulman | last post by:
I would like to add barcode functionality to my POS program How does one attach barcode reader is it usually USB port How can the program get the data read by the device Thank you, Samuel
4
by: djbaker | last post by:
Greetings, I would like to integrate a barcode scanner into the current project I am working on. I have been looking around teh web and with the exception of embeded devices I cannot find many...
7
by: Alper Ozgur | last post by:
Hi; How can i capture and decode the barcode that reading by an usb Barcode reader?
2
by: nmrpa91290 | last post by:
Hi, I am in the design phase of building a database that will track the productivity of my warehouse. I am thinking of using a barcode scanner to assist me with this. Employees will hopefully...
2
by: chris_gpf1 | last post by:
Hi, I'm working on a website where the user will have to scan a barcode with a serial barcode scanner. I get the scanner working and reading the barcode, but when I want to write the string in...
4
by: Gerry19 | last post by:
Hi All, I'm trying to monitor data passed from a USB Barcode scanner but I can't find any decent code examples of what I need to do, including any references I need to include. I know I need to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.