Results 1 to 4 of 4

Thread: [RESOLVED] Help with frustration.

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2013
    Posts
    3

    Resolved [RESOLVED] Help with frustration.

    I am trying to write a code to look up the weather in any given city. I have found I can do this using weather.com rss feeds and extracting the relevant strings. But to find the code for each individual city I have had to google search the site, the city etc. I think I need to use a web browser control to process the url of a "I'm feeling lucky" google search to get the weather.com address for the given city....

    my problem is that I want to get rid of the web browser / or blank it out when the page loads and I have the url. BUT I want to be able to use the same search again if I need to, so i used a hidden web browser and am trying to get it to return back to about:blank after I get the URL.

    my code so far is:

    Public Class Form1
    Public urlout As String = ""
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    WebBrowser1.ScriptErrorsSuppressed = True
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Dim city As String = TextBox1.Text
    Dim weathurl As String = "http://www.google.com/search?ie=UTF-8&oe=UTF-8&sourceid=navclient&btnI=1&q=" & city & "+weather+site%3Aweather.com"
    WebBrowser1.Navigate(weathurl)


    End Sub

    Private Sub WebBrowser1_DocumentCompleted(sender As Object, e As WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
    While WebBrowser1.IsBusy = False
    If WebBrowser1.Url.ToString().IndexOf("weather.com") Then

    urlout = (WebBrowser1.Url.ToString())
    WebBrowser1.Navigate("about:blank")
    TextBox2.Text = urlout

    ElseIf WebBrowser1.Url.ToString().IndexOf("about:blank") Then
    Exit While
    End If
    End While

    End Sub
    End Class


    However I get with this I get stuck in some sort of odd loop where the whole thing hangs and outputs :"Additional Information: Transition into COM context 0x69f138 for this RuntimeCallableWrapper failed with the following error: System call failed. (Exception from HRESULT: 0x80010100 (RPC_E_SYS_CALL_FAILED))."

    If I get rid of ElseIf WebBrowser1.Url.ToString().IndexOf("about:blank") Then
    Exit While

    The outputted URL gives about:blank..... I don't know if the document completed event is being access when about:blank is loaded????


    Any help or ideas would be appreciated! I thought this would be the easy bit!

  2. #2
    Fanatic Member AceInfinity's Avatar
    Join Date
    May 2011
    Posts
    696

    Re: Help with frustration.

    I would suggest a couple things here:

    1) Firstly, please use code tags. That's probably the reason why nobody else has responded to your thread. The code is not properly indented, and it's not in code tags either. This makes the code very frustrating for someone to read, and lots of people ignore threads like this because of that.
    2) Look into WebRequests. This WebBrowser strategy is nonsense.
    <<<------------
    Improving Managed Code Performance | .NET Application Performance
    < Please if this helped you out. Any kind of thanks is gladly appreciated >


    .NET Programming (2012 - 2018)
    ®Crestron - DMC-T Certified Programmer | Software Developer
    <<<------------

  3. #3
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    9,017

    Re: Help with frustration.

    You may be able to do what you're trying without the web browser by using the HttpWebRequest class.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  4. #4

    Thread Starter
    New Member
    Join Date
    May 2013
    Posts
    3

    Re: Help with frustration.

    Quote Originally Posted by Niya View Post
    You may be able to do what you're trying without the web browser by using the HttpWebRequest class.
    Thanks. Looked this up and it worked a charm. I'll make sure I use tags next time!

    Thanks x

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