If I have a string array in VB and I need to access a certain element of it many times, is it faster to store it in a separate string variable first?
Here is an ex of what I mean:
Private Function GetSuffix(delim As String) As String
Dim i As Integer
i = InStr(sl(sln), delim)
GetSuffix = Right(sl(sln), Len(sl(sln)) - i)
End Function
OR
Private Function GetSuffix(delim As String) As String
Dim i As Integer
Dim theStr As String
theStr = sl(sln)
i = InStr(theStr, delim)
GetSuffix = Right(theStr, Len(theStr) - i)
End Function
I understand that in the code I posted above the speed would probably not really be effected because sl(sln) is accessed only a few times. But what if I had it in a for loop or something. Would it be better the first or second way?