John,
To get a single character, use Mid. E.g,.
Dim C As String
C = Mid("abcdefg", 5, 1)
will put "e" in C (5th character, length 1)/
I'm used to strings
being arrays of characters so this seems mad!
Strings in
VB/VBA are actually what are called BSTRs, and part of
COM/OLE/Automation. See
http://msdn2.microsoft.com/en-us/library/ms221069.aspx
You can treat them as if they were arrays of characters. You can't use
pointers as you do in C/C++. Instead of a point to a character, you use an
1-based index into the string.
--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)
"John Pritchard" wrote in message
...
I wanted to read along a string character by character in VB and ended up
with a home made function :-
Public Function GetChr(ByVal InPutStr As String, ByVal position As
Integer)
As String
If position <= Len(InPutStr) Then
GetChr = Right(Left(InPutStr, position), 1)
Else
GetChr = Chr(0)
End If
End Function
Is there an easier (and more efficient) way than this. I'm used to strings
being arrays of characters so this seems mad!