473,387 Members | 1,791 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,387 software developers and data experts.

Capturing input from a textbox

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
11 2224
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
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
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
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Sharad Gupta | last post by:
i have this problem of capturing the filename on the instance when onclick is activated in the <body> the function should catch the filename and display it. Second problem, i have to catch the...
7
by: jerrygarciuh | last post by:
Hello, I have been playing with various Googled solutions for capturing the <Enter> key to suppress form submission. My first question is whether anyone has a script that works in all common...
33
by: Joerg Schuster | last post by:
Hello, Python regular expressions must not have more than 100 capturing groups. The source code responsible for this reads as follows: # XXX: <fl> get rid of this limitation! if...
2
by: George Durzi | last post by:
I have a text box and a button, and I want the enter key to run the click event of the button. The textbox and button are inside a user control. I tried all sorts of stuff with the __EVENTTARGET...
10
by: Andrew | last post by:
Hi, I have a messagebox that pops up due to an event. I did it in javascript. ie. alert("Time's up. Assessment Ended"); I want to capture the OK and Cancel events of this alert messagebox. My...
4
by: Bruce HS | last post by:
I do an autopostback from a text box in a datagrid template. How can I capture the event in the code behind? Handles DataGrid1.textboxname.TextChanged doesn't work, and I don't see any DataGrid...
3
by: Muriel | last post by:
I'm developing a website using visual studio .NET I have a login form with a couple of textboxes and a login button. What I want to do is capture the Enter key so that when the user presses...
2
by: jbigham | last post by:
Hello, I'd like to capture key events using javascript, but don't want to process such events when the user is typing into an input box or into a textarea. As an example, gmail has a feature...
9
RBPierce
by: RBPierce | last post by:
Hey all, hoping someone can help me with a workaround. I've got an event set to fire when a textbox changes or loses focus- no problems. However, when the user clicks into the box and Right Click-->...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.