Still better:Code:' ByRef instead of ByVal: no new string created ' lngPos: Long instead of Byte, Long is faster Private Function CountMembersContentChar(ByRef strChar As String, ByVal lngPos As Long) As Long Dim idx As Long Dim iCnt As Long Dim iChr As Integer ' cache the character code value iChr = AscW(strChar) ' Milk forgot to account for Base 1 with Mid$ -> MidB$ change lngPos = (lngPos - 1) * 2 + 1 For idx = 0 To UBound(Members) If lngPos <= LenB(Members(idx)) Then ' numeric comparison is way faster (compiled!) If AscW(MidB$(Members(idx), lngPos, 2)) = iChr Then iCnt = iCnt + 1 End If End If Next CountMembersContentChar = iCnt End Function




Reply With Quote