Hi, gang. I don't like to post here until I've exhausted myself first - well, I'm whooped.
I'm creating a project in MS Visual Studio 2012 using VB.net having converted the pre-existing code from VBA. So far I've been able to iron out any wrinkles, but this one's got me stumped.
I wrote a Search function in VBA:
Works like a charm. If the string being searched (txt) is found it moves the cursor to the bottom right of the found phrase.
Here's the VB version:
This causes a Type Mismatch error. In VBA the length of the object (if the search fails) is put to zero. Why isn't that happening in VB? Does anyone have a solution in VB that checks the Search function result?
Thanks a million,
Snason
I'm creating a project in MS Visual Studio 2012 using VB.net having converted the pre-existing code from VBA. So far I've been able to iron out any wrinkles, but this one's got me stumped.
I wrote a Search function in VBA:
Code:
Function aSearch(ByVal txt As String) As Boolean
Dim mySrch As Object
With xScreen
Set mySrch = .Search(txt)
If Len(mySrch) > 0 Then
.MoveTo mySrch.Bottom, mySrch.Right
aSearch = True
Else
aSearch = False
End If
End With
End Function
Here's the VB version:
Code:
Public Function aSearch(ByVal txt As String) As Boolean
Dim mySrch As Object
With scr
mySrch = .Search(txt)
If Len(mySrch) > 0 Then 'ERROR OCCURS HERE
.MoveTo(mySrch.bottom, mySrch.right)
aSearch = True
Else
aSearch = False
End If
End With
End Function
Thanks a million,
Snason