simple problem...?!

P

Peter Proost

Hi group,

I've got what seems a simple problem, but I can't find the solution. I've
got a textbox and a handheld scanner to scan barcodes, the scanner just
generates keypresses like a keyboard would so if I scan a barcode and the
number from this barcode is 4210, the scanner generates a keypress on the 4
than on the 2 than on 1 and finally on the 0. Now what's my problem, normaly
the barcodes' length always is 16 (so if the length of the textbox.text = 16
I select the entire text so the next barcode can be scanned), but If the
user for example scans the barcode wrong or to fast, only a piece of the
code is generated and my textbox length ain't 16 and the text doesn't get
selected, so if they scan a next barcode this barcode is wrong because it
fills the barcode textbox untill the length is 16 than selects the text and
continues with the remaining numbers. Now this would not be a big problem if
the user had a mouse or a keyboard but they only have got a scanner.

Any help is very welcome

thnx in advance Peter
 
C

Cor Ligthert

Peter,

I know almost nothing about barcodes.

However every string has a length property what can be tested.

dim a as string = "Hello"
if a.length <> 16 then 'messagebox.show("There is something wrong scan
again")

What do I mis in your problem?

Cor
 
P

Peter Proost

Hi Cor,

I know about the length property, the problem you miss is that the text in
the textbox has to be selected for a new scan to completly overwrite the
text in the textbox, and that's the problem the complete text in the textbox
always has to be selected, I already wrote a piece of code to always select
the entire text in the text box but the problem with that was that it didn't
overwrite the selected text but just added text to it. This would be very
easy if the scanner generated an end of input event or something like that
but it works just like a keyboard and a keyboard also hasn't got a end of
input thingy.

I hope the I was a bit clearer this time :)

Greetz Peter
 
C

Cor Ligthert

Peter,

Can you give a sample something as
Textbox contains 'xxxxxxxxxxxxx
Scanner contains 'xxxxxxxxxxxxxxxx

Result in textbox has to be 'xxxxxxxxxxxxx

Know that a 00 value ends a visiblestring however it still contains it.

Cor
 
P

Peter Proost

Cor,

here's an example:

I scan a barcode of normal length 16 and it returns me:

123456789abcdefh in the textbox and in the text changed event I check to see
if my textbox.text.length is 16 if this is the case I set the selectionstart
and length.

now the next barcode I scan is a wrong one and it returns only 10
characters:

123456789a to the textbox, in my text changed event I check and see that the
length isn't 16 so I don't set the selectionstart and length, but it should
be selected because if I do a new correct scan the text which was in the
textbox has to disapear.

If the scanner would send the entire string at once it wouldn't be a
problem, the textchanged event would do just fine but the scanner doesn't
send what it scans as a complete string, but it sends it like I would type
it in on a keyboard (character per character)

I hope this helps to clear it up

greetz Peter
 
C

Cor Ligthert

Peter,

Sorry,

It still not is, how you know the scanner is ready.
(I hope you are not just looking for the method textbox.clear")

And just some short answers, more words does not clear it for me. You mis
something and I mis something (I do not see what tells that the barcode
action has ended).

Cor
 
P

Peter Proost

Hi Cor

That's the problem nothing tells me that the barcode action has ended, it's
just the same as I would type in a 16 digit code in a textbox, there's no
event firing when I stop typing, the scanner just reads the barcode and
sends it to the screen character by character like I would do if I typed it
on my keyboard letter by letter

Peter
 
A

Aaron Smith

Peter,

Do you make the barcodes yourself? Do your barcodes end with any special
characters? Are they all the exact same length?

We print barcodes from our software. We put *'s at the beginning and the
end of the barcode. Then we have just check every time the text is
changed, if the string is larger than 1 and the last character is a *,
we move on to the next field... Just as an example...

Aaron
 
C

Cor Ligthert

Peter,

However it is scanning, and than doing if it is typing.

So with the first keypress you can set a timer, and than when there are some
milliseconds gone you can test if it is done.

As you wrote it is simple in my opinion. I think that it can be something as
the sample bellow.

However I cannot do the timing that you have to set yourself, because this
what I set is to slow

\\\
Private WithEvents timer1 As New Timer
Private firstkey As Boolean
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e _
As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If firstkey = False Then
timer1.Enabled = True
timer1.Interval = 1000
End If
End Sub
Private Sub timer1_Tick(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles timer1.Tick
firstkey = False
timer1.Enabled = False
If TextBox1.Text.Length < 16 Then
MessageBox.Show("something was wrong")
End If
End Sub
///

I hope this helps?

Cor
 
P

Peter Proost

Hi Cor thnx for your time, I've found a solution... and a very easy one, at
first I was told that there wasn't a possibility to connect a mouse to the
terminal on which the programm has to run using citrix, but now I got one in
my hands and a mouse port is available, so problem solved thnx again for
your time and effort and I'll tell the hardware guy at work to look better
in the future thnx again
 
C

C-Services Holland b.v.

Peter said:
Cor,

here's an example:

I scan a barcode of normal length 16 and it returns me:

123456789abcdefh in the textbox and in the text changed event I check to see
if my textbox.text.length is 16 if this is the case I set the selectionstart
and length.

now the next barcode I scan is a wrong one and it returns only 10
characters:

123456789a to the textbox, in my text changed event I check and see that the
length isn't 16 so I don't set the selectionstart and length, but it should
be selected because if I do a new correct scan the text which was in the
textbox has to disapear.

If the scanner would send the entire string at once it wouldn't be a
problem, the textchanged event would do just fine but the scanner doesn't
send what it scans as a complete string, but it sends it like I would type
it in on a keyboard (character per character)

I hope this helps to clear it up

greetz Peter
Use a timer with a timeout of 1 second? Scanning it is like typing very
fast. If the textbox isn't full within that second clear it.
 
C

Cor Ligthert

Rinze,

Use a timer with a timeout of 1 second? Scanning it is like typing very
fast. If the textbox isn't full within that second clear it.
That is exactly my sample from yesterday. Why you write this.

However Peter did not needed it anymore.

Cor
 
C

C-Services Holland b.v.

Cor said:
Rinze,




That is exactly my sample from yesterday. Why you write this.

However Peter did not needed it anymore.

Cor
Hmm sorry, I missed that post before replying.. my bad
 

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

Top