473,480 Members | 3,098 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Counting characters entered in a text box and ...

Using VBA code on a form, does anyone know the most effective way to
count characters entered into a text box AS they are being entered and
displaying the number of characters remaining to the user?

Thanks
Nov 13 '05 #1
4 32885
Use the Change event of the text box to count the Len() of the Text
property, and assign the result to an unbound text box:

Private Sub Text1_Change()
Me.Text2 = 255 - Len(Me.Text1.Text)
End Sub

The example assumes there are 255 charaters available. If the control is
bound to a Text field, you could get the number of charaters from:
Me.RecordsetClone.Fields("MyField").Size

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Lauren Wilson" <???@???.???> wrote in message
news:m4********************************@4ax.com...
Using VBA code on a form, does anyone know the most effective way to
count characters entered into a text box AS they are being entered and
displaying the number of characters remaining to the user?

Thanks

Nov 13 '05 #2

Well Allen, I tried this. The change event does seem to fire with
EACH keystroke inside the text box but the value it uses for the
calculation is always the old value (Me.txtObjectName).

What I need to do is decrement the character counter on EACH keystroke
and update the remaining character count even before the record is
saved. I've tried using the Keypress event but that has it's own set
of problems.

Is there a way to have a real-time display of the remaining characters
as the user types into the field but before they save the record?

Thanks again for all your great contributions to this group.
On Thu, 16 Sep 2004 12:55:37 +0800, "Allen Browne"
<Al*********@SeeSig.Invalid> wrote:
Use the Change event of the text box to count the Len() of the Text
property, and assign the result to an unbound text box:

Private Sub Text1_Change()
Me.Text2 = 255 - Len(Me.Text1.Text)
End Sub

The example assumes there are 255 charaters available. If the control is
bound to a Text field, you could get the number of charaters from:
Me.RecordsetClone.Fields("MyField").Size

Nov 13 '05 #3
Did you actually test the TEXT property of the control,i.e.:
Len(Me.txtObjectName.Text)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Lauren Wilson" <???@???.???> wrote in message
news:vn********************************@4ax.com...

Well Allen, I tried this. The change event does seem to fire with
EACH keystroke inside the text box but the value it uses for the
calculation is always the old value (Me.txtObjectName).

What I need to do is decrement the character counter on EACH keystroke
and update the remaining character count even before the record is
saved. I've tried using the Keypress event but that has it's own set
of problems.

Is there a way to have a real-time display of the remaining characters
as the user types into the field but before they save the record?

Thanks again for all your great contributions to this group.
On Thu, 16 Sep 2004 12:55:37 +0800, "Allen Browne"
<Al*********@SeeSig.Invalid> wrote:
Use the Change event of the text box to count the Len() of the Text
property, and assign the result to an unbound text box:

Private Sub Text1_Change()
Me.Text2 = 255 - Len(Me.Text1.Text)
End Sub

The example assumes there are 255 charaters available. If the control is
bound to a Text field, you could get the number of charaters from:
Me.RecordsetClone.Fields("MyField").Size

Nov 13 '05 #4
On Sun, 19 Sep 2004 16:13:09 +0800, "Allen Browne"
<Al*********@SeeSig.Invalid> wrote:
Did you actually test the TEXT property of the control,i.e.:
Len(Me.txtObjectName.Text)


OOPS! No I did not. Geesh! I'm such a doofus sometimes.
Thanks for your patience.
Nov 13 '05 #5

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

Similar topics

9
3380
by: Bob Alston | last post by:
In 2002, "GrayJay" posted the following code: I did this in a jazz record catalogue to find composers - On a form "frmComposers" Create a text box - txtFindComposer, and add the following sub...
1
4250
by: David Smith | last post by:
What I want to be able to do: A textbox is available that the user can enter information into. Specifically (for the purposes of this post), the user is asked to enter a number, and that number...
3
1373
by: Brent | last post by:
Say that I have a text box that holds 5 lines of text. If the user enters ten text lines, I want the first four lines of text displayed, followed by a "More" hyperlink. The link will pop up another...
5
7655
by: andy.lee23 | last post by:
hi im having trouble counting lines in a text file, i have the following code int node1, node2, i; char name; float value; ifstream fin; fin.open(OpenDialog1->FileName.c_str()); i=1;
5
13099
by: faizankhan666 | last post by:
Complete homework Question is this: Create a program that uses a do-while loop to count the number of char. (not including whitespace) entered by the user.The count should end when it encounters...
0
1675
by: abcd | last post by:
I have a wxTextCtrl: wx.TextCtrl(self.myPanel, -1, "", style=wx.TE_MULTILINE) I take a set of text (65,000 characters), and paste it into the text control. all looks well. Then when I click...
1
2602
by: meryline | last post by:
hi, iam new to c#, can any one tell me how to find the total number characters entered in a textbox. like in vb.net i find it using len(textbox.text) . iam trying to implement the same in c# sharp...
0
835
by: =?Utf-8?B?U3BlZWR5?= | last post by:
Hi, how does one enter characters of a foreign language in a text field? In particular, I am trying to enter the s with caron on top. In Word I would type <Ctrl>+<Alt>+^ followed by the s. This...
5
1611
by: fressanme | last post by:
i would like to ask if there is an existing algorithm for counting characters from a text file? if there is,can i have a sample?
0
7055
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,...
0
6920
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7061
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,...
1
6763
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
5367
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,...
0
4503
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...
0
3015
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1313
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 ...
1
574
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.