Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to count characters in a variable

Posted on 2001-07-16
3
Medium Priority
?
172 Views
Last Modified: 2012-06-22
Could anyone let me know a simple way of counting the number of characters within a variable including spaces, i.e variable x contains text "hello i need a count:" therefore variable y = 21.
0
Comment
Question by:dustybryn
  • 2
3 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 150 total points
ID: 6286031
?Len(x)

This will return 21.

0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6286036
To expand a little:

Dim x As String
Dim y As String
x = "hello i need a count:"
y = Len(x)
Msgbox "The Following Text: " & vbLF & x & vbLF & "Has " & CStr(y) & " Characters In It."
0
 

Author Comment

by:dustybryn
ID: 6286051
Cheers Tim. I know the question is dead basic but I haven't been in this game long and have had no training! I appreciate the rapid response.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question