Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Attachmate Extra Search function in VB.NET 1

Status
Not open for further replies.

SnasonJoe

Programmer
Oct 21, 2013
7
US
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:
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
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:
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
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
 
SkipVought,

You're the best! I hope a total stranger buys you a beer tonight!

Snason
 
Well I'm buying my wife dinner at On The Border tonight. Maybe a kind soul will buy us something. ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top