How to count the number of digits in a field while typing -with vba code?

goldben5

New member
Local time
Today, 00:22
Joined
Apr 17, 2018
Messages
2
Hello everyone,
How to count the number of digits in a field while typing -with vba code?
Thank you in advance,

Benjamin Goldenberg
 
Not sure that I've understood the requirement correctly but perhaps:

MsgBox Len(Me.ActiveControl.Text)

in the On Change event of a textbox control.
 
Not sure that I've understood the requirement correctly but perhaps:

MsgBox Len(Me.ActiveControl.Text)

in the On Change event of a textbox control.
My thoughts were the O/P wanted to count digits in something like Th1s1sMyPa55w0rd
 
what do you mean "digits"? numbers?
you need to add Change event to your textbox and
count the digit there.
see this demo, open Form1 and type anything
in the first textbox.
 

Attachments

If you mean that the field in question will ALWAYS be numeric and you are looking at its length, there are other questions to ask. Such as... Will it involve decimal points? Are you using the "thousands" separators (either comma or dot depending on regional settings)? Do you have mixed digit and alphabetic characters and you are trying to determine the count of digits in a mixed field? Please specify what you seek.
 
Digits = Numbers, Characters = anything. That seems to be what is causing the confusion. Regardless, You would use the Change event of the textbox. This fires once for each each character typed as arnel suggested.
 

Users who are viewing this thread

Back
Top Bottom