473,775 Members | 2,610 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
11 2264
WriteLine write the data and a carriage return to end the line. Use the
Write method instead.

--
Patrice

<dt*******@dunh amshq.coma écrit dans le message de news:
11************* *********@50g20 00...legro ups.com...
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(Re adString)
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...@dunh amshq.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.WriteLi ne(TextBox1.Tex t)
oWrite.Flush ()
oWrite.Close ()
>See if that helps.
>Steve C.
MCSD,MCAD,MCSE ,MCP+I,CNE,CNA, CCNA
>dterib...@dunh amshq.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
automaticall y, 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,MC P+I,CNE,CNA,CCN A
dterib...@du nhamshq.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.Strea mWriter
oWrite = oFile.CreateTex t("C:\sample2.t xt")
oWrite.WriteLin e(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,C CNA
dt*******@dunha mshq.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(Re adString)
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...@dunh amshq.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.Write Line(TextBox1.T ext)
oWrite.Flush ()
oWrite.Close ()
See if that helps.
Steve C.
MCSD,MCAD,MC SE,MCP+I,CNE,CN A,CCNA
dterib...@du nhamshq.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
>automatica lly, and yours probably does to. If you look for that
>characte r 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,C CNA
>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.Strea mWriter
oWrite = oFile.CreateTex t("C:\sample2.t xt")
oWrite.WriteLin e(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
15867
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 image name in the same fashion using =onclick showimage(this). Is this possible at at I have tried all combinations of document.getElementbyId(); document.getElementbyName(); document.getElementbyTagName();
7
20372
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 browsers? The script bellow is IE only. It fails FF 1.0 and NN 7. Also, if I can trap the keypress I would like to use it to tab to the next tabindex.
33
5645
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 p.pattern.groups > 100: raise AssertionError( "sorry, but this version only supports 100 named groups"
2
14685
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 hidden field with no luck. Here's what I'm doing function KeyDownHandler(btn) { if (event.keyCode == 13) {
10
6022
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 code is in C#/ASP.NET. TIA. Andrew.
4
7123
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 events appropriate for a textchanged event. Please respond, and save me a $245 support call to MS!
3
1747
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 Enter, it will click the submit button. I have searched the Internet for hours now trying to find out how to do it, but any methods that I have seen do not work. Can anyone help me do that?
2
2280
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 where you can type "r" anywhere on the page while viewing a message and it will open a reply box, but if you type an "r" while entering text into a form, it doesn't do this. My question is how to do this most efficiently.
9
24422
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--> Pastes a value into it, I can't get any event to fire. I've tried onClick, OnChange, OnMouseDown, onMouseUp, onKeyDown, and onKeyUp. <input type='text' onChange="alert('Changed')" onClick="alert('Clicked')" onMouseDown="alert('onMouseDown')"...
0
9622
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10268
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10107
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8939
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7464
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6718
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5486
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4017
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2853
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.