By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,793 Members | 1,252 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,793 IT Pros & Developers. It's quick & easy.

Capturing input from a textbox

P: n/a
Hello,

I am trying to make a program that when someone uses a scanner to scan
a barcode that the number will automaticly be entered into a .txt
file. I tired to use the most of the events and none have seemed to
work .Does anyone have any ideas. I and using VB.net 2005. Thank you

Aug 24 '07 #1
Share this Question
Share on Google+
11 Replies


P: n/a
My barcode scanners (Intermec) add a CRLF to the end of the text
automatically, and yours probably does to. If you look for that
character on the KeyDown event, you should be able to pick up the text
and use the System.IO namespace classes to write the file.
Steve C.
MCAD,MCSE,MCP+I,CNE,CNA,CCNA
dt*******@dunhamshq.com wrote:
Hello,

I am trying to make a program that when someone uses a scanner to scan
a barcode that the number will automaticly be entered into a .txt
file. I tired to use the most of the events and none have seemed to
work .Does anyone have any ideas. I and using VB.net 2005. Thank you
Aug 24 '07 #2

P: n/a
On Aug 24, 10:43 am, Steve <lnuxguy_NOMAIL_PLEA...@gmail.comwrote:
My barcode scanners (Intermec) add a CRLF to the end of the text
automatically, and yours probably does to. If you look for that
character on the KeyDown event, you should be able to pick up the text
and use the System.IO namespace classes to write the file.

Steve C.
MCAD,MCSE,MCP+I,CNE,CNA,CCNA

dterib...@dunhamshq.com wrote:
Hello,
I am trying to make a program that when someone uses a scanner to scan
a barcode that the number will automaticly be entered into a .txt
file. I tired to use the most of the events and none have seemed to
work .Does anyone have any ideas. I and using VB.net 2005. Thank you- Hide quoted text -

- Show quoted text -
Steve,

Thank you for that idea. I will have to try that out and see what
happens.

Aug 24 '07 #3

P: n/a
dt*******@dunhamshq.com wrote:
On Aug 24, 10:43 am, Steve <lnuxguy_NOMAIL_PLEA...@gmail.comwrote:
>My barcode scanners (Intermec) add a CRLF to the end of the text
automatically, and yours probably does to. If you look for that
character on the KeyDown event, you should be able to pick up the text
and use the System.IO namespace classes to write the file.

Steve C.
MCAD,MCSE,MCP+I,CNE,CNA,CCNA

dterib...@dunhamshq.com wrote:
>>Hello,
I am trying to make a program that when someone uses a scanner to scan
a barcode that the number will automaticly be entered into a .txt
file. I tired to use the most of the events and none have seemed to
work .Does anyone have any ideas. I and using VB.net 2005. Thank you- Hide quoted text -
- Show quoted text -

Steve,

Thank you for that idea. I will have to try that out and see what
happens.
Also,
Take a look at the com port "serialport" object as well.
Some new scanners are USB and they have a driver that actually assigns a
com port to the USB port of a scanner.
So what I do is I have teh SerialPort listening to a comport and flush
that to the "topmost" application or to whatever textbox I need to.

Miro
Aug 24 '07 #4

P: n/a
On Aug 24, 11:29 am, Miro <miron...@golden.netwrote:
dterib...@dunhamshq.com wrote:
On Aug 24, 10:43 am, Steve <lnuxguy_NOMAIL_PLEA...@gmail.comwrote:
My barcode scanners (Intermec) add a CRLF to the end of the text
automatically, and yours probably does to. If you look for that
character on the KeyDown event, you should be able to pick up the text
and use the System.IO namespace classes to write the file.
Steve C.
MCAD,MCSE,MCP+I,CNE,CNA,CCNA
dterib...@dunhamshq.com wrote:
Hello,
I am trying to make a program that when someone uses a scanner to scan
a barcode that the number will automaticly be entered into a .txt
file. I tired to use the most of the events and none have seemed to
work .Does anyone have any ideas. I and using VB.net 2005. Thank you- Hide quoted text -
- Show quoted text -
Steve,
Thank you for that idea. I will have to try that out and see what
happens.

Also,
Take a look at the com port "serialport" object as well.
Some new scanners are USB and they have a driver that actually assigns a
com port to the USB port of a scanner.
So what I do is I have teh SerialPort listening to a comport and flush
that to the "topmost" application or to whatever textbox I need to.

Miro- Hide quoted text -

- Show quoted text -
Miro,

I will also look into this one. I will have to see what will work be
for this application. Thank you again.

Aug 24 '07 #5

P: n/a
On Aug 24, 10:43 am, Steve <lnuxguy_NOMAIL_PLEA...@gmail.comwrote:
My barcode scanners (Intermec) add a CRLF to the end of the text
automatically, and yours probably does to. If you look for that
character on the KeyDown event, you should be able to pick up the text
and use the System.IO namespace classes to write the file.

Steve C.
MCAD,MCSE,MCP+I,CNE,CNA,CCNA

dterib...@dunhamshq.com wrote:
Hello,
I am trying to make a program that when someone uses a scanner to scan
a barcode that the number will automaticly be entered into a .txt
file. I tired to use the most of the events and none have seemed to
work .Does anyone have any ideas. I and using VB.net 2005. Thank you- Hide quoted text -

- Show quoted text -
Steve,

I did code this as follows. However I am having the problem of it only
getting the last digit of the serial number. Can you give me a little
more help.
Dim oFile As System.IO.File
Dim oWrite As System.IO.StreamWriter

oWrite = oFile.CreateText("C:\sample2.txt")
oWrite.WriteLine(TextBox1.Text)
oWrite.Close()
TextBox1.Text = ""
End Sub
Aug 27 '07 #6

P: n/a
You're missing the .Flush() call before you close the StreamWriter. It
should be something like this:

oWrite.WriteLine(TextBox1.Text)
oWrite.Flush()
oWrite.Close()

See if that helps.
Steve C.
MCSD,MCAD,MCSE,MCP+I,CNE,CNA,CCNA
dt*******@dunhamshq.com wrote:
On Aug 24, 10:43 am, Steve <lnuxguy_NOMAIL_PLEA...@gmail.comwrote:
>My barcode scanners (Intermec) add a CRLF to the end of the text
automatically, and yours probably does to. If you look for that
character on the KeyDown event, you should be able to pick up the text
and use the System.IO namespace classes to write the file.

Steve C.
MCAD,MCSE,MCP+I,CNE,CNA,CCNA

dterib...@dunhamshq.com wrote:
>>Hello,
I am trying to make a program that when someone uses a scanner to scan
a barcode that the number will automaticly be entered into a .txt
file. I tired to use the most of the events and none have seemed to
work .Does anyone have any ideas. I and using VB.net 2005. Thank you- Hide quoted text -
- Show quoted text -

Steve,

I did code this as follows. However I am having the problem of it only
getting the last digit of the serial number. Can you give me a little
more help.
Dim oFile As System.IO.File
Dim oWrite As System.IO.StreamWriter

oWrite = oFile.CreateText("C:\sample2.txt")
oWrite.WriteLine(TextBox1.Text)
oWrite.Close()
TextBox1.Text = ""
End Sub

Aug 27 '07 #7

P: n/a
On Aug 27, 10:01 am, Steve <lnuxguy_NOMAIL_PLEA...@gmail.comwrote:
You're missing the .Flush() call before you close the StreamWriter. It
should be something like this:

oWrite.WriteLine(TextBox1.Text)
oWrite.Flush()
oWrite.Close()

See if that helps.

Steve C.
MCSD,MCAD,MCSE,MCP+I,CNE,CNA,CCNA

dterib...@dunhamshq.com wrote:
On Aug 24, 10:43 am, Steve <lnuxguy_NOMAIL_PLEA...@gmail.comwrote:
My barcode scanners (Intermec) add a CRLF to the end of the text
automatically, and yours probably does to. If you look for that
character on the KeyDown event, you should be able to pick up the text
and use the System.IO namespace classes to write the file.
Steve C.
MCAD,MCSE,MCP+I,CNE,CNA,CCNA
dterib...@dunhamshq.com wrote:
Hello,
I am trying to make a program that when someone uses a scanner to scan
a barcode that the number will automaticly be entered into a .txt
file. I tired to use the most of the events and none have seemed to
work .Does anyone have any ideas. I and using VB.net 2005. Thank you- Hide quoted text -
- Show quoted text -
Steve,
I did code this as follows. However I am having the problem of it only
getting the last digit of the serial number. Can you give me a little
more help.
Dim oFile As System.IO.File
Dim oWrite As System.IO.StreamWriter
oWrite = oFile.CreateText("C:\sample2.txt")
oWrite.WriteLine(TextBox1.Text)
oWrite.Close()
TextBox1.Text = ""
End Sub- Hide quoted text -

- Show quoted text -
It did not help. It has something to do with how I am clearing the
text box at the end. If I comment out textbox1.text out this part of
the code I can get the whole sku to show up in my file. If i had to
delete the old sku from the textbox everytime this would defeat the
purpose.
Aug 27 '07 #8

P: n/a
So if you don't clear the textbox, it works fine. Then you say that you
don't want to clear the textbox. So what's the problem? (I think I'm
missing something...)

Also, you can simplify the code more by passing the filename string
directly to the constructor of StreamWriter. Then you don't need oFile
at all.
Steve C.
MCSD,MCAD,MCSE,MCP+I,CNE,CNA,CCNA
dt*******@dunhamshq.com wrote:
On Aug 27, 10:01 am, Steve <lnuxguy_NOMAIL_PLEA...@gmail.comwrote:
>You're missing the .Flush() call before you close the StreamWriter. It
should be something like this:

oWrite.WriteLine(TextBox1.Text)
oWrite.Flush()
oWrite.Close()

See if that helps.

Steve C.
MCSD,MCAD,MCSE,MCP+I,CNE,CNA,CCNA

dterib...@dunhamshq.com wrote:
>>On Aug 24, 10:43 am, Steve <lnuxguy_NOMAIL_PLEA...@gmail.comwrote:
My barcode scanners (Intermec) add a CRLF to the end of the text
automatically, and yours probably does to. If you look for that
character on the KeyDown event, you should be able to pick up the text
and use the System.IO namespace classes to write the file.
Steve C.
MCAD,MCSE,MCP+I,CNE,CNA,CCNA
dterib...@dunhamshq.com wrote:
Hello,
I am trying to make a program that when someone uses a scanner to scan
a barcode that the number will automaticly be entered into a .txt
file. I tired to use the most of the events and none have seemed to
work .Does anyone have any ideas. I and using VB.net 2005. Thank you- Hide quoted text -
- Show quoted text -
Steve,
I did code this as follows. However I am having the problem of it only
getting the last digit of the serial number. Can you give me a little
more help.
Dim oFile As System.IO.File
Dim oWrite As System.IO.StreamWriter
oWrite = oFile.CreateText("C:\sample2.txt")
oWrite.WriteLine(TextBox1.Text)
oWrite.Close()
TextBox1.Text = ""
End Sub- Hide quoted text -
- Show quoted text -

It did not help. It has something to do with how I am clearing the
text box at the end. If I comment out textbox1.text out this part of
the code I can get the whole sku to show up in my file. If i had to
delete the old sku from the textbox everytime this would defeat the
purpose.

Aug 27 '07 #9

P: n/a
Steve,

No I do want to clear the text box. I want them to be able to scan all
the items without having to touch a mouse or keyboard. I found
different code and it will let me clear it but it lines up funny. I
have posted the Code and the output below.
Dim fw As StreamWriter

Dim ReadString As String

Try
'Pass the file path and name to the StreamWriter
constructor.
'Indicate that Append is True, so file will not be
overwritten.
fw = New StreamWriter("C:\sample2.txt", True)
ReadString = TextBox2.Text
fw.WriteLine(ReadString)
Finally
'Close the file.
fw.Close()

End Try
TextBox2.Text = ""

I get this for output in the sample.txt file.
1
2
3
4
5
6

I want it to be:
123456

Thank you again for all your help.

On Aug 27, 11:35 am, Steve <lnuxguy_NOMAIL_PLEA...@gmail.comwrote:
So if you don't clear the textbox, it works fine. Then you say that you
don't want to clear the textbox. So what's the problem? (I think I'm
missing something...)

Also, you can simplify the code more by passing the filename string
directly to the constructor of StreamWriter. Then you don't need oFile
at all.

Steve C.
MCSD,MCAD,MCSE,MCP+I,CNE,CNA,CCNA

dterib...@dunhamshq.com wrote:
On Aug 27, 10:01 am, Steve <lnuxguy_NOMAIL_PLEA...@gmail.comwrote:
You're missing the .Flush() call before you close the StreamWriter. It
should be something like this:
oWrite.WriteLine(TextBox1.Text)
oWrite.Flush()
oWrite.Close()
See if that helps.
Steve C.
MCSD,MCAD,MCSE,MCP+I,CNE,CNA,CCNA
dterib...@dunhamshq.com wrote:
On Aug 24, 10:43 am, Steve <lnuxguy_NOMAIL_PLEA...@gmail.comwrote:
My barcode scanners (Intermec) add a CRLF to the end of the text
automatically, and yours probably does to. If you look for that
character on the KeyDown event, you should be able to pick up the text
and use the System.IO namespace classes to write the file.
Steve C.
MCAD,MCSE,MCP+I,CNE,CNA,CCNA
dterib...@dunhamshq.com wrote:
Hello,
I am trying to make a program that when someone uses a scanner to scan
a barcode that the number will automaticly be entered into a .txt
file. I tired to use the most of the events and none have seemed to
work .Does anyone have any ideas. I and using VB.net 2005. Thank you- Hide quoted text -
- Show quoted text -
Steve,
I did code this as follows. However I am having the problem of it only
getting the last digit of the serial number. Can you give me a little
more help.
Dim oFile As System.IO.File
Dim oWrite As System.IO.StreamWriter
oWrite = oFile.CreateText("C:\sample2.txt")
oWrite.WriteLine(TextBox1.Text)
oWrite.Close()
TextBox1.Text = ""
End Sub- Hide quoted text -
- Show quoted text -
It did not help. It has something to do with how I am clearing the
text box at the end. If I comment out textbox1.text out this part of
the code I can get the whole sku to show up in my file. If i had to
delete the old sku from the textbox everytime this would defeat the
purpose.- Hide quoted text -

- Show quoted text -

Aug 27 '07 #10

P: n/a
WriteLine write the data and a carriage return to end the line. Use the
Write method instead.

--
Patrice

<dt*******@dunhamshq.coma écrit dans le message de news:
11**********************@50g2000hsm.googlegroups.c om...
Steve,

No I do want to clear the text box. I want them to be able to scan all
the items without having to touch a mouse or keyboard. I found
different code and it will let me clear it but it lines up funny. I
have posted the Code and the output below.
Dim fw As StreamWriter

Dim ReadString As String

Try
'Pass the file path and name to the StreamWriter
constructor.
'Indicate that Append is True, so file will not be
overwritten.
fw = New StreamWriter("C:\sample2.txt", True)
ReadString = TextBox2.Text
fw.WriteLine(ReadString)
Finally
'Close the file.
fw.Close()

End Try
TextBox2.Text = ""

I get this for output in the sample.txt file.
1
2
3
4
5
6

I want it to be:
123456

Thank you again for all your help.

On Aug 27, 11:35 am, Steve <lnuxguy_NOMAIL_PLEA...@gmail.comwrote:
>So if you don't clear the textbox, it works fine. Then you say that you
don't want to clear the textbox. So what's the problem? (I think I'm
missing something...)

Also, you can simplify the code more by passing the filename string
directly to the constructor of StreamWriter. Then you don't need oFile
at all.

Steve C.
MCSD,MCAD,MCSE,MCP+I,CNE,CNA,CCNA

dterib...@dunhamshq.com wrote:
On Aug 27, 10:01 am, Steve <lnuxguy_NOMAIL_PLEA...@gmail.comwrote:
You're missing the .Flush() call before you close the StreamWriter. It
should be something like this:
>oWrite.WriteLine(TextBox1.Text)
oWrite.Flush()
oWrite.Close()
>See if that helps.
>Steve C.
MCSD,MCAD,MCSE,MCP+I,CNE,CNA,CCNA
>dterib...@dunhamshq.com wrote:
On Aug 24, 10:43 am, Steve <lnuxguy_NOMAIL_PLEA...@gmail.comwrote:
My barcode scanners (Intermec) add a CRLF to the end of the text
automatically, and yours probably does to. If you look for that
character on the KeyDown event, you should be able to pick up the
text
and use the System.IO namespace classes to write the file.
Steve C.
MCAD,MCSE,MCP+I,CNE,CNA,CCNA
dterib...@dunhamshq.com wrote:
Hello,
I am trying to make a program that when someone uses a scanner to
scan
a barcode that the number will automaticly be entered into a .txt
file. I tired to use the most of the events and none have seemed to
work .Does anyone have any ideas. I and using VB.net 2005. Thank
you- Hide quoted text -
- Show quoted text -
Steve,
I did code this as follows. However I am having the problem of it
only
getting the last digit of the serial number. Can you give me a little
more help.
Dim oFile As System.IO.File
Dim oWrite As System.IO.StreamWriter
oWrite = oFile.CreateText("C:\sample2.txt")
oWrite.WriteLine(TextBox1.Text)
oWrite.Close()
TextBox1.Text = ""
End Sub- Hide quoted text -
- Show quoted text -
It did not help. It has something to do with how I am clearing the
text box at the end. If I comment out textbox1.text out this part of
the code I can get the whole sku to show up in my file. If i had to
delete the old sku from the textbox everytime this would defeat the
purpose.- Hide quoted text -

- Show quoted text -


Aug 27 '07 #11

P: n/a
In your example, if 1, 2, 3, 4, 5, and 6 are individual SKUs, then you
need to use fw.Write() instead of fw.WriteLine().

If they're actually one SKU spread out over 6 lines, then you may have
an extended ASCII character (like a CRLF) being inserted between each
"normal" character. You may need to do some cleanup of the string before
you store it, to remove any unwanted characters.
Steve C.
MCSD,MCAD,MCSE,MCP+I,CNE,CNA,CCNA
dt*******@dunhamshq.com wrote:
Steve,

No I do want to clear the text box. I want them to be able to scan all
the items without having to touch a mouse or keyboard. I found
different code and it will let me clear it but it lines up funny. I
have posted the Code and the output below.
Dim fw As StreamWriter

Dim ReadString As String

Try
'Pass the file path and name to the StreamWriter
constructor.
'Indicate that Append is True, so file will not be
overwritten.
fw = New StreamWriter("C:\sample2.txt", True)
ReadString = TextBox2.Text
fw.WriteLine(ReadString)
Finally
'Close the file.
fw.Close()

End Try
TextBox2.Text = ""

I get this for output in the sample.txt file.
1
2
3
4
5
6

I want it to be:
123456

Thank you again for all your help.

On Aug 27, 11:35 am, Steve <lnuxguy_NOMAIL_PLEA...@gmail.comwrote:
>So if you don't clear the textbox, it works fine. Then you say that you
don't want to clear the textbox. So what's the problem? (I think I'm
missing something...)

Also, you can simplify the code more by passing the filename string
directly to the constructor of StreamWriter. Then you don't need oFile
at all.

Steve C.
MCSD,MCAD,MCSE,MCP+I,CNE,CNA,CCNA

dterib...@dunhamshq.com wrote:
>>On Aug 27, 10:01 am, Steve <lnuxguy_NOMAIL_PLEA...@gmail.comwrote:
You're missing the .Flush() call before you close the StreamWriter. It
should be something like this:
oWrite.WriteLine(TextBox1.Text)
oWrite.Flush()
oWrite.Close()
See if that helps.
Steve C.
MCSD,MCAD,MCSE,MCP+I,CNE,CNA,CCNA
dterib...@dunhamshq.com wrote:
On Aug 24, 10:43 am, Steve <lnuxguy_NOMAIL_PLEA...@gmail.comwrote:
>My barcode scanners (Intermec) add a CRLF to the end of the text
>automatically, and yours probably does to. If you look for that
>character on the KeyDown event, you should be able to pick up the text
>and use the System.IO namespace classes to write the file.
>Steve C.
>MCAD,MCSE,MCP+I,CNE,CNA,CCNA
>dterib...@dunhamshq.com wrote:
>>Hello,
>>I am trying to make a program that when someone uses a scanner to scan
>>a barcode that the number will automaticly be entered into a .txt
>>file. I tired to use the most of the events and none have seemed to
>>work .Does anyone have any ideas. I and using VB.net 2005. Thank you- Hide quoted text -
>- Show quoted text -
Steve,
I did code this as follows. However I am having the problem of it only
getting the last digit of the serial number. Can you give me a little
more help.
Dim oFile As System.IO.File
Dim oWrite As System.IO.StreamWriter
oWrite = oFile.CreateText("C:\sample2.txt")
oWrite.WriteLine(TextBox1.Text)
oWrite.Close()
TextBox1.Text = ""
End Sub- Hide quoted text -
- Show quoted text -
It did not help. It has something to do with how I am clearing the
text box at the end. If I comment out textbox1.text out this part of
the code I can get the whole sku to show up in my file. If i had to
delete the old sku from the textbox everytime this would defeat the
purpose.- Hide quoted text -
- Show quoted text -

Aug 27 '07 #12

This discussion thread is closed

Replies have been disabled for this discussion.