如何计算备注字段中的剩余字符 [英] how to count the remaining characters in a memo field

查看:98
本文介绍了如何计算备注字段中的剩余字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,你好
我想知道如何计算要在备注字段中输入的剩余字符数.
我正在使用备注字段从用户那里获取文本.我已限制用户只能在该字段中输入最多140个字符.因此,在那种情况下,我编写了用于计数剩余字符的代码.我在以下事件中尝试过.

Hello, Everybody
I want to know that how can I count the remaining number of characters to be entered in a memo field.
I am using a memo field for taking texts from user. I have restricted to user that he/she can entered maximum 140 characters in the field. So, in which event I have written the code for count the remaining characters. I have tried in the following event.

Private Sub txtMessage_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtMessage.KeyDown
  If e.KeyCode = Keys.Return Then
    Call NotesFocus(txtMessage)
  Else
    lblBalanceChar.Text = 140 - (txtMessage.Text.Count + 1) & " Characters remaining"
  End If
End Sub



它如何工作.但是有一些错误.
如果有人建议对他/她表示感谢.

问候
Subrat,:cool :: cool :: cool:
桌面应用程序开发人员
印度



It works some how. but there are some error.
If anybody suggest Grateful to him/her.

Regards
Subrat,:cool::cool::cool:
Desktop Application Developer
India

推荐答案

处理TextChanged事件,并将textBox.Text.Length与所需值(在您的情况下为140)进行比较.
但是,我认为有一个属性可以让您指定TextBox ...
Handle the TextChanged event, and compare textBox.Text.Length to the desired value (in your case, 140).

However, I thought there was a property that allowed you to specify the max text length of a TextBox...


这篇关于如何计算备注字段中的剩余字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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