A
andy.bayley
Hi
I'm using this bit of code (thanks to Lyle Fairfield) to help me find
the text after the third forward slash in a field.
An example field may be 1/2345/6/78 - and I wish to return 78.
Please could someone let me know hot to amend this code so that if
there is no third forward slash, the function will return a zero?
Currently it returns some other number!
Function RAT(strSearchIn As String, strSearchFor As String, occurences
As Long)
As Integer
Dim aSearchIn() As Byte, intCounter As Integer, bytSearchFor As
Byte
Dim occurence As Long
For occurence = 1 To occurences
aSearchIn = StrConv(strSearchIn, vbFromUnicode)
bytSearchFor = Asc(strSearchFor)
For intCounter = UBound(aSearchIn) To LBound(aSearchIn) Step -1
If aSearchIn(intCounter) = bytSearchFor Then
RAT = intCounter + 1
Exit For
End If
Next intCounter
Next
End Function
Thanks!
Andy.
I'm using this bit of code (thanks to Lyle Fairfield) to help me find
the text after the third forward slash in a field.
An example field may be 1/2345/6/78 - and I wish to return 78.
Please could someone let me know hot to amend this code so that if
there is no third forward slash, the function will return a zero?
Currently it returns some other number!
Function RAT(strSearchIn As String, strSearchFor As String, occurences
As Long)
As Integer
Dim aSearchIn() As Byte, intCounter As Integer, bytSearchFor As
Byte
Dim occurence As Long
For occurence = 1 To occurences
aSearchIn = StrConv(strSearchIn, vbFromUnicode)
bytSearchFor = Asc(strSearchFor)
For intCounter = UBound(aSearchIn) To LBound(aSearchIn) Step -1
If aSearchIn(intCounter) = bytSearchFor Then
RAT = intCounter + 1
Exit For
End If
Next intCounter
Next
End Function
Thanks!
Andy.