Results 1 to 3 of 3

Thread: vb6 simple web browser runtime errors

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2018
    Posts
    2

    vb6 simple web browser runtime errors

    hello to all. I am a beginner. this is my first post. I did search some but there is such a plethora of info here I couldn't seem to find what I was looking for so I decided it would be easier if I just asked. I have made the simplest of a web browser. heres how basic it is

    Private Sub Form_Load()

    WebBrowser1.Navigate2 "http://www.dogpile.com"

    End Sub

    Private Sub mnuBack_Click()

    WebBrowser1.GoBack

    End Sub

    Private Sub mnuBite_Click()

    WebBrowser1.Stop

    End Sub

    Private Sub mnuCrawl_Click()

    WebBrowser1.Navigate txtSpider.Text

    End Sub

    Private Sub mnuForward_Click()

    WebBrowser1.GoForward

    End Sub

    Private Sub mnuSpin_Click()

    WebBrowser1.Refresh

    End Sub

    Private Sub mnuWeb_Click()

    WebBrowser1.GoHome

    End Sub

    Now while it works fine and runs, if you run it and click the mnuBack or mnuForward without first having gone somewhere, the result is a runtime error.


    so my question is there an easy way that I can stop this from happening and how? thanks in advance


    note: just in case anyone was wondering I named it arachnid hence all the references to spiders since it is a web crawler after all lol

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: vb6 simple web browser runtime errors

    probably you should disable the back and forward buttons o start, until there is something to go back or forward to then enable
    a forward button only has something to go to if you already went back 1 or more times, so you need to keep track, if after going back, you click some new link then forward should again be disabled
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2018
    Posts
    2

    Re: vb6 simple web browser runtime errors

    thank you pete. I have already tried something to that effect and wasn't able to get it to work. I think what I did was something like I disabled both buttons in the form load then had it check in the mnuback_click event to see if webbrowser1 had navigated if so to enable the back and then the same in the forward to see if the back had been clicked if so then enable the forward. unfortunately it didn't work for me. I wonder if there is some way I could get it to work with msgbox. or maybe if I changed from the menu to command buttons.


    I will definitely keep you all updated. thanks. Out of curiosity why do you say avoid On Error Resume Next?

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