Hi Paul - thanks for your quick response.
I have tried your function but get an error:
Error 1 Overload resolution failed because no accessible 'InStr' can be called without a narrowing conversion:
'Public Function InStr(Start As Integer, String1 As String, String2 As String, [Compare As Microsoft.VisualBasic.Comp
'Public Function InStr(String1 As String, String2 As String, [Compare As Microsoft.VisualBasic.Comp
'Public Function InStr(String1 As String, String2 As String, [Compare As Microsoft.VisualBasic.Comp
I'm building a VB windows forms app in Visual Studio 2005
Main Topics
Browse All Topics





by: PaulHewsPosted on 2008-01-05 at 08:59:15ID: 20589624
Option Explicit
Private Sub Command1_Click()
Dim strTest As String
strTest = "this is a test"
Debug.Print GetSecondPos(strTest, "t")
End Sub
Private Function GetSecondPos(strText As String, strSub As String) As Long
Dim lngPos As Long
lngPos = InStr(1, strText, strSub)
If lngPos > 0 Then
lngPos = InStr(lngPos + 1, strText, strSub)
End If
GetSecondPos = lngPos
End Function