计算文本框上的字符(但在键入时)。 [英] Count Characters on a Textbox (but while typing).
问题描述
如果你能帮我正确编码文本框中剩下的倒计时字符,我将不胜感激。
这是我的代码,但实时无法工作,我的意思是,当我键入TxtBox2。
TextBox3是我放置计数器的地方。
TextBox2就是文本的位置。
>
//
Private Sub TextBox3_Change()
Me.TextBox3 = 250 - Len(Me.TextBox2.Text)& "剩下的字符
如果Len(Me.TextBox2.Text)= 250则
MsgBox不允许更多字符!
结束如果
结束Sub
//
提前致谢。
Dan
我不确定,但我认为您可以在输入时使用计时器控制来计算字符数。
在其他论坛我刚读过这篇文章,但不确定它是否有效:
//
Me.LblCharsLeft.Caption = 255 - Len(Trim(Me.TextBox))& "剩下的字符
//
我需要一个实时的计数器,所以当我输入TextBox 2时需要在某个地方有一个计数器告诉TextBox2剩下多少字符。
再次感谢。
对不起。您不必使用定时器控件。
您可以使用以下代码...
展开 | 选择 | Wrap | 行号< /跨度>
Please I would appreciate if you can help me with the correct code to countdown characters left in a TextBox.
Here is my code but doesn''t work on real time, I mean, when I type in TxtBox2.
TextBox3 is where I put the counter.
TextBox2 is where it''s the text.
//
Private Sub TextBox3_Change()
Me.TextBox3 = 250 - Len(Me.TextBox2.Text) & " Characters Left"
If Len(Me.TextBox2.Text) = 250 Then
MsgBox "No more characters allowed!"
End If
End Sub
//
Thanks in advance.
Dan解决方案I am not sure, but I think you can use timer control for count the characters while typing.
In other forum I''ve just read this but not sure if it will work:
//
Me.LblCharsLeft.Caption = 255 - Len(Trim(Me.TextBox)) & " characters left"
//
I need a counter on real time, so when I type in TextBox 2 need in someplace a counter that tells how many character left in TextBox2.
Thanks again.
I am sorry. You don''t have to use the timer control.
You can use the following code...
Expand|Select|Wrap|Line Numbers
这篇关于计算文本框上的字符(但在键入时)。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文