Solved

Syntax to extract individual characters from VBA string

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

758 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

19 Experts available now in Live!

Get 1:1 Help Now