View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Charles Williams Charles Williams is offline
external usenet poster
 
Posts: 968
Default Accessing substrings quickly

If you need to access several of the individual characters in the string, or
handle the characters as numbers, it can be faster to use a Byte array:

Private Sub somebytes()

Dim aBytes() As Byte
Dim StrLongString As String
Dim strChar As String

StrLongString = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
aBytes = StrLongString
strChar = Chr(aBytes(8))
MsgBox strChar

End Sub

Charles
___________________________________
The Excel Calculation Site
http://www.decisionmodels.com

"Robert Crandal" wrote in message
...
Do I need to use the "Mid" function each time I want
to access a substring??

For example, rather than using the following:

mysubstring = Mids(src, 5, 1) ' get 5th character/string

can't I use some other array/index notation
like the following:

mysubstring = src(5)

I get the impression that my code would run a lot faster
if I could access my substrings by an index, rather than
making calls to functions such as Mids(), Instr(), etc....

thank u