Dear all expert programmers,
I plan to create some function to count number of members's name that is content specified character and specified position of character and want fast process. Please optimize my code to make it fast if max array is 32767"
Thank you for all post.Code:Option Explicit Private Members(3) As String Private Sub Command1_Click() Members(0) = "Albert" Members(1) = "Ronal" Members(2) = "Micheal" Members(3) = "Alex" MsgBox CountMembersContentChar("A", 1) & vbCrLf & CountMembersContentChar("o", 2) End Sub Private Function CountMembersContentChar(ByVal strChar As String, ByVal lngPos As Byte) As Long Dim idx As Long Dim iCnt As Long For idx = 0 To UBound(Members) If lngPos <= Len(Members(idx)) Then If InStr(1, Members(idx), strChar, vbBinaryCompare) = lngPos Then iCnt = iCnt + 1 End If End If Next CountMembersContentChar = iCnt End Function




Reply With Quote