counting Charaters

S

Simon

I have some code that i want to use depending on how many charaters
have been enterer into txtBox

for examples

If txtBox has 8 characters then do follwoing code ........
If txtBox has 3 character then do this codes.........


I just do not know how to code it to count the charaters in a txt box
 
D

Dirk Goldgar

Simon said:
I have some code that i want to use depending on how many charaters
have been enterer into txtBox

for examples

If txtBox has 8 characters then do follwoing code ........
If txtBox has 3 character then do this codes.........


I just do not know how to code it to count the charaters in a txt box


The Len() function will tell you how long the text is:

Select Case Len(Me!txtBox & vbNullString)
Case 8
' Handle 8-character case
Case 3
' Handle 3-character case
Case Else
' Not 8 or 3; what now?
End Select

The reason for the "& vbNullString" is to force the value to a zero-length
string if it happens to be Null.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top