Solved

Syntax to extract individual characters from VBA string

Posted on 2008-10-30
3
1,629 Views
Last Modified: 2012-05-05
Probably an easy question, but how do I reference the individual characters of a string?  For example in order to extract each character one after another I thought it would be something like this:

Dim MyString As String
Dim MyChar As String

MyString = "abcd"

For index = 0 to Len MyString
    MyChar = MyString[index]   'this syntax is incorrect
Next index


Thanks.
0
Comment
Question by:JohnSantaFe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 22842558
MyChar = Mid(MySTring, index, 1)
0
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 500 total points
ID: 22842562
For index = 1 to Len(MyString)
    MyChar = Mid(MyString, index, 1)   'this syntax is incorrect
Next index
0
 

Author Comment

by:JohnSantaFe
ID: 22843206
Thank you.
0

Featured Post

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

734 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