Courtesy of yrwyddfa and I, with a few slight modifications:
VB Code:
Declare Sub RtlMoveMemory Lib "kernel32" ( _ ByRef lpvDest As Any, _ ByRef lpvSrc As Any, _ ByVal cbLen As Long _ ) Function InStr2CharCount( _ ByVal pszString As Long, _ ByRef pszFind1 As String, _ ByRef pszFind2 As String _ ) As Long Static chBuf(1024) As Byte Dim chSearchChar1 As Byte Dim chSearchChar2 As Byte Dim lStringLen As Long Dim i As Long RtlMoveMemory lStringLen, ByVal (pszString - 4), 4& RtlMoveMemory chBuf(0), ByVal pszString, lStringLen chSearchChar1 = AscW(pszFind1) chSearchChar2 = AscW(pszFind2) For i = 0 To lStringLen Step 2 If (chBuf(i) = chSearchChar1) Or (chBuf(i) = chSearchChar2) Then _ InStr2CharCount = InStr2CharCount + 1 Next i End Function ' Usage: MsgBox Instr2CharCount(StrPtr(Trim$(txtInput.Text)), ".", "?")




Reply With Quote