如何创建自动输入框。 [英] How to create an automated input box.

查看:100
本文介绍了如何创建自动输入框。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有下面的代码来评估一串字符。如果

小于12长,它会触发一个消息框,如果等于它

将保存信息并关闭表格。


我现在有一个按钮事件,我怎么能放置这个相同的

逻辑说一旦我输入我的最后一个字符它将触发逻辑

写入按钮控件。


Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As

System.EventArgs)处理btnOK.Click

如果Len(Me.txtBarCode.Text)= 12那么

_barcode = Me.txtBarCode.Text

关闭()

否则

MessageBox.Show(当前扫描的当前条形码不是

正确,请重新输入)

Me.txtBarCode.Text = String.Empty

txtBarCode.Focus()

结束如果

结束子

解决方案

1月4日晚上11点50分,cmdolcet69< colin_dolce ... @ hotmail.comwrote:


我有下面的代码来评估一串字符。如果

小于12长,它会触发一个消息框,如果等于它

将保存信息并关闭表格。


我现在有一个按钮事件,我怎么能放置这个相同的

逻辑说一旦我输入我的最后一个字符它将触发逻辑

写入按钮控件。


Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As

System.EventArgs)处理btnOK.Click

如果Len(Me.txtBarCode.Text)= 12那么

_barcode = Me.txtBarCode.Text

关闭()

否则

MessageBox.Show(当前扫描的当前条形码不是

正确,请重新输入)

Me.txtBarCode.Text = String.Empty

txtBarCode.Focus()

结束如果

结束Sub



加法:注意puttimer1.enabled = false

消息框之前,如果你没有禁用或禁用消息后每个OK

提示消息框流通将永远不会结束。


" cmdolcet69" < co ************ @ hotmail.comschrieb


我有下面的代码来评估一串字符。如果

小于12长,它会触发一个消息框,如果等于它

将保存信息并关闭表格。


我现在有一个按钮事件,我怎么能放置这个相同的

逻辑说一旦我输入我的最后一个字符它将触发写入的

逻辑按钮控件。


Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As

System.EventArgs)处理btnOK.Click

如果Len(Me.txtBarCode.Text)= 12那么

_barcode = Me.txtBarCode.Text

关闭()

否则

MessageBox.Show(当前扫描的当前条形码不是

正确,请重新输入)

Me.txtBarCode.Text = String.Empty

txtBarCode.Focus()

结束如果

结束Sub



将代码从Button1_Click移动到一个新子。在Click

处理程序中调用sub,另外在Textbox的'TextChanged事件中调用sub。 (但是,作为用户,

我希望能够编辑我输入的文本,直到我按下

按钮。)

Armin


Armin,


将代码从Button1_Click移动到新的子。在Click

处理程序中调用sub,另外在Textbox的'TextChanged事件中调用sub。 (但是,作为一个

的用户,我希望能够编辑我输入的文本,直到我按下按钮后按

。)



如果您只需要在一个表格上一小时输入1000个数字,您可能很高兴

很高兴不需要点击按钮。


我的经验是,在那些情况下,大多数用户甚至看不到他们在点击按钮时键入的内容。


(或者当它为12时将焦点设置在按钮上,然后让Enter键执行

这项工作以获得两者)


只是我的想法,


Cor


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

解决方案

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.


"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


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


这篇关于如何创建自动输入框。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆