473,382 Members | 1,313 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,382 software developers and data experts.

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 32850
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
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
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
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
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
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
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
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
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
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?
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...

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.