×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Attachmate Extra Search function in VB.NET

Attachmate Extra Search function in VB.NET

Attachmate Extra Search function in VB.NET

(OP)
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 --> VBA

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 --> VB

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

RE: Attachmate Extra Search function in VB.NET

Hi,

[code]

If Len(mySrch.Value) > 0 Then

RE: Attachmate Extra Search function in VB.NET

(OP)
SkipVought,

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

Snason

RE: Attachmate Extra Search function in VB.NET

Well I'm buying my wife dinner at On The Border tonight. Maybe a kind soul will buy us something. winky smile

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close