Solved

How to count characters in a variable

Posted on 2001-07-16
3
161 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
Comment Utility
?Len(x)

This will return 21.

0
 
LVL 43

Expert Comment

by:TimCottee
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now