473,406 Members | 2,816 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,406 software developers and data experts.

How to create an automated input box.

I have the code below that will evaluate a string of characters. If
its less then 12 long it will trigger a message box if its equal it
will save the information and close the form.

I have this currectly on a button event, how could i place this same
logic say once i enter in my last character it will trigger the logic
written in the button control.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnOK.Click
If Len(Me.txtBarCode.Text) = 12 Then
_barcode = Me.txtBarCode.Text
Close()
Else
MessageBox.Show("The Current BarCode Scanned was not
correct, Please Re Enter")
Me.txtBarCode.Text = String.Empty
txtBarCode.Focus()
End If
End Sub
Jan 4 '08 #1
11 1595
On Jan 4, 11:50 pm, cmdolcet69 <colin_dolce...@hotmail.comwrote:
I have the code below that will evaluate a string of characters. If
its less then 12 long it will trigger a message box if its equal it
will save the information and close the form.

I have this currectly on a button event, how could i place this same
logic say once i enter in my last character it will trigger the logic
written in the button control.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnOK.Click
If Len(Me.txtBarCode.Text) = 12 Then
_barcode = Me.txtBarCode.Text
Close()
Else
MessageBox.Show("The Current BarCode Scanned was not
correct, Please Re Enter")
Me.txtBarCode.Text = String.Empty
txtBarCode.Focus()
End If
End Sub
Addition: Pay attention to put "timer1.enabled = false" before
messagebox, if you don't disable or disable after messagebox every OK
prompt for messagebox circulation will never end.
Jan 4 '08 #2
"cmdolcet69" <co************@hotmail.comschrieb
I have the code below that will evaluate a string of characters. If
its less then 12 long it will trigger a message box if its equal it
will save the information and close the form.

I have this currectly on a button event, how could i place this same
logic say once i enter in my last character it will trigger the
logic written in the button control.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnOK.Click
If Len(Me.txtBarCode.Text) = 12 Then
_barcode = Me.txtBarCode.Text
Close()
Else
MessageBox.Show("The Current BarCode Scanned was not
correct, Please Re Enter")
Me.txtBarCode.Text = String.Empty
txtBarCode.Focus()
End If
End Sub
Move the code from Button1_Click into a new sub. Call the sub in the Click
handler and additionally in the Textbox' TextChanged event. (But, as a user,
I would like to be able to edit the text I entered until I pressed the
button.)
Armin

Jan 4 '08 #3
Armin,

Move the code from Button1_Click into a new sub. Call the sub in the Click
handler and additionally in the Textbox' TextChanged event. (But, as a
user, I would like to be able to edit the text I entered until I pressed
the button.)
If you have only on a form to enter 1000 numbers in an hour you be probably
glad that there is no button click needed.

My expirience is that in those situations mostly the users don't even look
what they have typed when clicking the button.

(Or set the focus on the Button when it is 12 and then let the Enter key do
this job to get both)

Just my thought,

Cor

Jan 5 '08 #4
"Cor Ligthert[MVP]" <no************@planet.nlschrieb
Armin,

Move the code from Button1_Click into a new sub. Call the sub in
the Click handler and additionally in the Textbox' TextChanged
event. (But, as a user, I would like to be able to edit the text I
entered until I pressed the button.)
If you have only on a form to enter 1000 numbers in an hour you be
probably glad that there is no button click needed.

My expirience is that in those situations mostly the users don't
even look what they have typed when clicking the button.

(Or set the focus on the Button when it is 12 and then let the Enter
key do this job to get both)

Just my thought,
Ok, I see. The OP might have reasons why he needs it, that's why I only
wrote my comment in braces. :-)
Armin

Jan 5 '08 #5
On Jan 4, 5:06*pm, "Armin Zingler" <az.nos...@freenet.dewrote:
"cmdolcet69" <colin_dolce...@hotmail.comschrieb


I have the code below that will evaluate a string of characters. If
its less then 12 long it will trigger a message box if its *equal it
will save the information and close the form.
I have this currectly on a button event, how could i place this same
logic say once i enter in my last character it will trigger the
logic written in the button control.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnOK.Click
* * * *If Len(Me.txtBarCode.Text) = 12 Then
* * * * * *_barcode = Me.txtBarCode.Text
* * * * * *Close()
* * * *Else
* * * * * *MessageBox.Show("The Current BarCode Scanned was not
correct, Please Re Enter")
* * * * * *Me.txtBarCode.Text = String.Empty
* * * * * *txtBarCode.Focus()
* * * *End If
* *End Sub

Move the code from Button1_Click into a new sub. Call the sub in the Click
handler and additionally in the Textbox' TextChanged event. (But, as a user,
I would like to be able to edit the text I entered until I pressed the
button.)

Armin- Hide quoted text -

- Show quoted text -
Armin, if i move the code or create another sub and place it under the
text change event. Each time i enter a number i get the message box
because the text change event is evaluating it each time.
Jan 6 '08 #6
That is the normal behaviour,

However don't botter about that, you see this while debugging, however not
one human can type that quick that he can be faster than that (even not
with repeating the key).

Cor
"cmdolcet69" <co************@hotmail.comschreef in bericht
news:75**********************************@t1g2000p ra.googlegroups.com...
On Jan 4, 5:06 pm, "Armin Zingler" <az.nos...@freenet.dewrote:
"cmdolcet69" <colin_dolce...@hotmail.comschrieb


I have the code below that will evaluate a string of characters. If
its less then 12 long it will trigger a message box if its equal it
will save the information and close the form.
I have this currectly on a button event, how could i place this same
logic say once i enter in my last character it will trigger the
logic written in the button control.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnOK.Click
If Len(Me.txtBarCode.Text) = 12 Then
_barcode = Me.txtBarCode.Text
Close()
Else
MessageBox.Show("The Current BarCode Scanned was not
correct, Please Re Enter")
Me.txtBarCode.Text = String.Empty
txtBarCode.Focus()
End If
End Sub

Move the code from Button1_Click into a new sub. Call the sub in the Click
handler and additionally in the Textbox' TextChanged event. (But, as a
user,
I would like to be able to edit the text I entered until I pressed the
button.)

Armin- Hide quoted text -

- Show quoted text -
Armin, if i move the code or create another sub and place it under the
text change event. Each time i enter a number i get the message box
because the text change event is evaluating it each time.

Jan 6 '08 #7
Correction,
>
However don't botter about that, you see this while debugging, however not
one human can type that quick that he can be faster than that (even not
with repeating the key).
I am glad Stephany not yet did see this one "he/she"

Cor

Jan 6 '08 #8
On Sat, 5 Jan 2008 19:11:02 -0800 (PST), cmdolcet69
<co************@hotmail.comwrote:
>On Jan 4, 5:06*pm, "Armin Zingler" <az.nos...@freenet.dewrote:
>"cmdolcet69" <colin_dolce...@hotmail.comschrieb


I have the code below that will evaluate a string of characters. If
its less then 12 long it will trigger a message box if its *equal it
will save the information and close the form.
I have this currectly on a button event, how could i place this same
logic say once i enter in my last character it will trigger the
logic written in the button control.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnOK.Click
* * * *If Len(Me.txtBarCode.Text) = 12 Then
* * * * * *_barcode = Me.txtBarCode.Text
* * * * * *Close()
* * * *Else
* * * * * *MessageBox.Show("The Current BarCode Scanned was not
correct, Please Re Enter")
* * * * * *Me.txtBarCode.Text = String.Empty
* * * * * *txtBarCode.Focus()
* * * *End If
* *End Sub

Move the code from Button1_Click into a new sub. Call the sub in the Click
handler and additionally in the Textbox' TextChanged event. (But, as a user,
I would like to be able to edit the text I entered until I pressed the
button.)

Armin- Hide quoted text -

- Show quoted text -

Armin, if i move the code or create another sub and place it under the
text change event. Each time i enter a number i get the message box
because the text change event is evaluating it each time.
Of course. You need to call your Sub only when the user has entered
the last character. It is up to you to decide what that means.

One possibility is to call the Sub only when Me.Text.Length = 12.
Jan 6 '08 #9
Jack,
Of course. You need to call your Sub only when the user has entered
the last character. It is up to you to decide what that means.

One possibility is to call the Sub only when Me.Text.Length = 12.
It seems that Armin and I miss something, can you show us how to do that?

This all is about measuring WHEN the 12th character is entered.
Cor
Jan 6 '08 #10
"Jack Jackson" <jj******@cinnovations.netschrieb
Armin, if i move the code or create another sub and place it under
the text change event. Each time i enter a number i get the
message box
because the text change event is evaluating it each time.

Of course. You need to call your Sub only when the user has entered
the last character. It is up to you to decide what that means.

One possibility is to call the Sub only when Me.Text.Length = 12.
Right, that's what I've overlooked. Thx.
In addition, in the Button_Click event, the check for the length 12 can be
left out, because, the Form has already been closed /before/ in the
TextChanged event. In other words, if the user has the time to click the
button, the length is never 12. (Is this correct?)

So,..

Private Sub Button1_Click( _
ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles btnOK.Click

MessageBox.Show( _
"The Current BarCode Scanned was not correct, Please Re Enter" _
)
Me.txtBarCode.Text = String.Empty
txtBarCode.Focus()

End Sub

private sub txtbarcode_Textchanged(...) handles txtbarcode.textchanged

If Len(Me.txtBarCode.Text) = 12 Then
_barcode = Me.txtBarCode.Text
Close()
end if

end sub
Armin

Jan 6 '08 #11

"cmdolcet69" <co************@hotmail.comha scritto
On Jan 4, 5:06 pm, "Armin Zingler" <az.nos...@freenet.dewrote:
"cmdolcet69" <colin_dolce...@hotmail.comschrieb
I have the code below that will evaluate a string of characters. If
its less then 12 long it will trigger a message box if its equal it
will save the information and close the form.
I have this currectly on a button event, how could i place this same
logic say once i enter in my last character it will trigger the
logic written in the button control.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnOK.Click
If Len(Me.txtBarCode.Text) = 12 Then
_barcode = Me.txtBarCode.Text
Close()
Else
MessageBox.Show("The Current BarCode Scanned was not
correct, Please Re Enter")
Me.txtBarCode.Text = String.Empty
txtBarCode.Focus()
End If
End Sub

Move the code from Button1_Click into a new sub. Call the sub in the Click
handler and additionally in the Textbox' TextChanged event. (But, as a
user,
I would like to be able to edit the text I entered until I pressed the
button.)

Armin- Hide quoted text -

- Show quoted text -
>Armin, if i move the code or create another sub and place it under the
text change event. Each time i enter a number i get the message box
because the text change event is evaluating it each time.

Private Sub txtChartSize_LostFocus(ByVal sender As Object, ByVal e As
System.EventArgs) Handles txtChartSize.LostFocus
MessageBox.Show(txtChartSize.Text.Trim.Length.ToSt ring)
End Sub

or

Private Sub txtChartSize_Validating(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles txtChartSize.Validating
If txtChartSize.Text.Trim.Length < 12 Then MessageBox.Show( _
"HEY! You lost " & (12 - txtChartSize.Text.Trim.Length).ToString
& " chars!")
End Sub

hth, ciao, ZC

Jan 6 '08 #12

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

Similar topics

21
by: Stefan Richter | last post by:
Hi, after coding for days on stupid form validations - Like: strings (min / max length), numbers(min / max value), money(min / max value), postcodes(min / max value), telefon numbers, email...
4
by: ScoobyDoo | last post by:
Anyone know how I can create and edit batch files from MS Access 2002?
6
by: saturnius | last post by:
Hello, I have to create data input forms to capture data (for sql server). I was just wondering weather there is an automated way (like using the datagrid) to link the "textbox.text" with the...
0
by: Benny | last post by:
I have an automated application to manipulate multiple Office documents. When the process is opening the documents, some of them run into security issues, macro errors, and anything else that...
6
by: brettev | last post by:
World, I work at a university where the professors have a system to input grades for assignments and calculate final grades, which is output to an excel file. they are then required to get on a...
23
by: sandy | last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory', within my class Directory (Can you already smell disaster?) Each Directory can have subdirectories so I thought to put these...
1
by: smith | last post by:
check this tool ..completely automated browser compatibility testing tool ..amazing!!! http://www.essentiabct.com
12
by: mr_marcin | last post by:
Hi Does anybody have some idea how to input some text into inputbox on one page, than press some button on that page, that will load another page, and finally read the responde? Suppose I want...
2
by: Fresno Bob | last post by:
I am looking at continous integration for automatic builds, unit testing etc. Is there anything to automate security testing for SQL injection, XSS? Preferably something cheap - some of the...
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
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.