Solved

Syntax to extract individual characters from VBA string

Posted on 2008-10-30
3
1,624 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Recently Microsoft released a brand new function called CONCAT. It's supposed to replace its predecessor CONCATENATE. But how does it work? And what's new? In this article, we take a closer look at all of this - we even included an exercise file for…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

895 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