Solved

How to count characters in a variable

Posted on 2001-07-16
3
164 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 50 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

829 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