|
-
Jan 3rd, 2007, 03:51 AM
#1
Thread Starter
Addicted Member
[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:
Private Sub doSearchQuery()
Dim google As String = "http://www.google.com/search?hl=en&q=" 'Google's search engine string
Dim yahoo As String = "http://search.yahoo.com/search;_ylt=A0geuoxASo1FZw4AFj2l87UF?ei=UTF-8&fr=sfp&p=" 'Yahoo's search engine string
Dim googleId As String = "btnG"
Dim Click As String = "click"
'Dim helement As New HtmlElement
Try
If lbSearchSelect = "Google" Then
wbPKMN.Navigate(google & SearchString) 'Navigate to google
wbPKMN.Document.GetElementById("btnG").InvokeMember(Click)
Else
wbPKMN.Navigate(yahoo & SearchString) 'navigate to yahoo
wbPKMN.Document.GetElementById("yschqcon").InvokeMember(Click)
End If
Catch ex As Exception
nwWriteLogMsg(ex.Message, ".\nwpps2k6err.log", ex.StackTrace, ex.TargetSite.ToString, ex.Source, ex.HelpLink)
With frmException
.lblTitle.Text = "UriFormatException"
.txtDesc.Text = ex.Message & " Error Number: " & Err.Number
.lblSource.Text = ex.Source
.lblTargetMethod.Text = ex.TargetSite.ToString
.ctbSTrace.Text = ex.StackTrace
.ShowDialog(Me)
End With
End Try
LbSearch.Hide()
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
-
Jan 3rd, 2007, 03:56 AM
#2
Fanatic Member
Re: [2005] How to get around error 91
-
Jan 3rd, 2007, 03:58 AM
#3
Thread Starter
Addicted Member
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
-
Jan 3rd, 2007, 04:02 AM
#4
Fanatic Member
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....
-
Jan 3rd, 2007, 04:14 AM
#5
Thread Starter
Addicted Member
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
-
Jan 3rd, 2007, 08:15 AM
#6
Re: [2005] How to get around error 91
 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:
Private Sub doSearchQuery()
Dim google As String = "http://www.google.com/search?hl=en&q=" 'Google's search engine string
Dim yahoo As String = "http://search.yahoo.com/search;_ylt=A0geuoxASo1FZw4AFj2l87UF?ei=UTF-8&fr=sfp&p=" 'Yahoo's search engine string
Dim googleId As String = "btnG"
Dim Click As String = "click"
'Dim helement As New HtmlElement
Try
If lbSearchSelect = "Google" Then
wbPKMN.Navigate(google & SearchString) 'Navigate to google
wbPKMN.Document.GetElementById("btnG").InvokeMember(Click)
Else
wbPKMN.Navigate(yahoo & SearchString) 'navigate to yahoo
wbPKMN.Document.GetElementById("yschqcon").InvokeMember(Click)
End If
Catch ex As Exception
nwWriteLogMsg(ex.Message, ".\nwpps2k6err.log", ex.StackTrace, ex.TargetSite.ToString, ex.Source, ex.HelpLink)
With frmException
.lblTitle.Text = "UriFormatException"
.txtDesc.Text = ex.Message & " Error Number: " & Err.Number
.lblSource.Text = ex.Source
.lblTargetMethod.Text = ex.TargetSite.ToString
.ctbSTrace.Text = ex.StackTrace
.ShowDialog(Me)
End With
End Try
LbSearch.Hide()
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:
Dim Google As string = Process.Start("www.google.com")
Hope it helps,
sparrow1
-
Jan 3rd, 2007, 08:27 AM
#7
Thread Starter
Addicted Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|