Results 1 to 7 of 7

Thread: [RESOLVED] [2005] How to get around error 91

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Location
    London, England
    Posts
    142

    Resolved [RESOLVED] [2005] How to get around error 91

    Hey folks, I've been working on adding a couple of search engines to my IE clone, but everytime i run the program, i always get this msg

    Object reference not set to an instance of an object. Error Number: 91
    the documentation on .GetElementById and .InvokeMember is sketchy at best, i've tried msdn, this forum, google, and all the other tricks i know, can anyone help?

    Here's my code

    VB Code:
    1. Private Sub doSearchQuery()
    2.         Dim google As String = "http://www.google.com/search?hl=en&q=" 'Google's search engine string
    3.         Dim yahoo As String = "http://search.yahoo.com/search;_ylt=A0geuoxASo1FZw4AFj2l87UF?ei=UTF-8&fr=sfp&p=" 'Yahoo's search engine string
    4.         Dim googleId As String = "btnG"
    5.         Dim Click As String = "click"
    6.         'Dim helement As New HtmlElement
    7.  
    8.         Try
    9.  
    10.             If lbSearchSelect = "Google" Then
    11.                 wbPKMN.Navigate(google & SearchString) 'Navigate to google
    12.                 wbPKMN.Document.GetElementById("btnG").InvokeMember(Click)
    13.  
    14.             Else
    15.                 wbPKMN.Navigate(yahoo & SearchString) 'navigate to yahoo
    16.                 wbPKMN.Document.GetElementById("yschqcon").InvokeMember(Click)
    17.             End If
    18.         Catch ex As Exception
    19.             nwWriteLogMsg(ex.Message, ".\nwpps2k6err.log", ex.StackTrace, ex.TargetSite.ToString, ex.Source, ex.HelpLink)
    20.             With frmException
    21.                 .lblTitle.Text = "UriFormatException"
    22.                 .txtDesc.Text = ex.Message & " Error Number: " & Err.Number
    23.                 .lblSource.Text = ex.Source
    24.                 .lblTargetMethod.Text = ex.TargetSite.ToString
    25.                 .ctbSTrace.Text = ex.StackTrace
    26.                 .ShowDialog(Me)
    27.             End With
    28.         End Try
    29.  
    30.         LbSearch.Hide()
    31.     End Sub

    The funny thing about this is, it works, even though it's throwing that error everytime. Just wonder if there's a way around it

    Redmo
    Last edited by redmo; Jan 3rd, 2007 at 03:59 AM. Reason: Including whole code block
    The universal aptitude for ineptitude makes any human accomplishment an incredible miracle -Col. John P. Stapp


    Please rate the posts that have helped. Makes us feel all warm and fuzzy

  2. #2
    Fanatic Member Ruku's Avatar
    Join Date
    Jul 2002
    Location
    Canada
    Posts
    655

    Re: [2005] How to get around error 91

    try catch?

    Using VB.NET 2005/.NET 2.0, NetBeans IDE 5, Fujitsu Cobol85,
    Website: http://DreamForgery.com

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Location
    London, England
    Posts
    142

    Re: [2005] How to get around error 91

    i'm already running a try, catch, i'll edit the code above to show the full routine, might give ye a better idea of what's goin on

    Redmo
    The universal aptitude for ineptitude makes any human accomplishment an incredible miracle -Col. John P. Stapp


    Please rate the posts that have helped. Makes us feel all warm and fuzzy

  4. #4
    Fanatic Member Ruku's Avatar
    Join Date
    Jul 2002
    Location
    Canada
    Posts
    655

    Re: [2005] How to get around error 91

    I think the problem is that you are not giving parameters to the click event... (such as sender and mousevents as e), to prevent these errors, you should probably move your click event code to a sub and call it instead of provoking a click....


    Using VB.NET 2005/.NET 2.0, NetBeans IDE 5, Fujitsu Cobol85,
    Website: http://DreamForgery.com

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Location
    London, England
    Posts
    142

    Re: [2005] How to get around error 91

    i'm not sure i fully understand, but when the user enters their query into the searchbox, both the keypress, and the go button fire of the doSearchQuery routine(the 1 above). I have nothing else in either of the other routines, except a check to make sure a search engine's selected..

    Redmo
    The universal aptitude for ineptitude makes any human accomplishment an incredible miracle -Col. John P. Stapp


    Please rate the posts that have helped. Makes us feel all warm and fuzzy

  6. #6
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: [2005] How to get around error 91

    Quote Originally Posted by redmo
    Hey folks, I've been working on adding a couple of search engines to my IE clone, but everytime i run the program, i always get this msg



    the documentation on .GetElementById and .InvokeMember is sketchy at best, i've tried msdn, this forum, google, and all the other tricks i know, can anyone help?

    Here's my code

    VB Code:
    1. Private Sub doSearchQuery()
    2.         Dim google As String = "http://www.google.com/search?hl=en&q=" 'Google's search engine string
    3.         Dim yahoo As String = "http://search.yahoo.com/search;_ylt=A0geuoxASo1FZw4AFj2l87UF?ei=UTF-8&fr=sfp&p=" 'Yahoo's search engine string
    4.         Dim googleId As String = "btnG"
    5.         Dim Click As String = "click"
    6.         'Dim helement As New HtmlElement
    7.  
    8.         Try
    9.  
    10.             If lbSearchSelect = "Google" Then
    11.                 wbPKMN.Navigate(google & SearchString) 'Navigate to google
    12.                 wbPKMN.Document.GetElementById("btnG").InvokeMember(Click)
    13.  
    14.             Else
    15.                 wbPKMN.Navigate(yahoo & SearchString) 'navigate to yahoo
    16.                 wbPKMN.Document.GetElementById("yschqcon").InvokeMember(Click)
    17.             End If
    18.         Catch ex As Exception
    19.             nwWriteLogMsg(ex.Message, ".\nwpps2k6err.log", ex.StackTrace, ex.TargetSite.ToString, ex.Source, ex.HelpLink)
    20.             With frmException
    21.                 .lblTitle.Text = "UriFormatException"
    22.                 .txtDesc.Text = ex.Message & " Error Number: " & Err.Number
    23.                 .lblSource.Text = ex.Source
    24.                 .lblTargetMethod.Text = ex.TargetSite.ToString
    25.                 .ctbSTrace.Text = ex.StackTrace
    26.                 .ShowDialog(Me)
    27.             End With
    28.         End Try
    29.  
    30.         LbSearch.Hide()
    31.     End Sub

    The funny thing about this is, it works, even though it's throwing that error everytime. Just wonder if there's a way around it

    Redmo
    Hi,

    You could try something like this;

    VB Code:
    1. Dim Google As string =  Process.Start("www.google.com")

    Hope it helps,

    sparrow1
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Location
    London, England
    Posts
    142

    Re: [2005] How to get around error 91

    I kinda solved the problem by just not showing the user the exception msg generated. I know this is wrong, and i'm going to burn in hell, but what the hell, it works. I already know, HtmlElement is very poorly documented, anyone else know how to use it properly...

    btw, system diagnostics.process, cannot be converted into a string.

    Redmo
    The universal aptitude for ineptitude makes any human accomplishment an incredible miracle -Col. John P. Stapp


    Please rate the posts that have helped. Makes us feel all warm and fuzzy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width