Results 1 to 3 of 3

Thread: Help me optimize this?

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2007
    Posts
    9

    Help me optimize this?

    Alright so I've got a program that plays a game for me and moves around the rooms of the city. Sometimes if the server lags it loses track and keeps running. Since it reads where to go from a listbox it just continues on and wastes time.

    Code:
    Private Sub wbNav_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    On Error Resume Next
    If (WebPageContains("go to a room not next to it.") = True) Then
        Call errorDetected
        errorYes = True
    ElseIf (URL = GAME+"/world.php" And errorYes = True) Then
        Call errorFixer
    End If
    lblCurrent.Caption = (Replace(URL, GAME, ""))
    End Sub
    
    
    '''''
    'Error Fixing and Detection!
    '''''
    
    Private Function errorDetected()
    tmrInterval.Enabled = False
    wbNav.Navigate (GAME+"/world.php")
    End Function
    Private Function errorFixer()
    On Error Resume Next
    Dim imagesrc As String, karaOke As Integer, argh As String
    argh = wbNav.Document.images(3).src
    If (WebPageContains("/images/world/map/")) Then
        imagesrc = (wbNav.Document.images(3).src)
        If (StrComp(argh, "/images/world/crewadv.jpg", vbTextCompare) = 0) Then
                imagesrc = (wbNav.Document.images(4).src)
        ElseIf (StrComp(argh, "/images/world/mobtalk.jpg", vbTextCompare) = 0) Then
                imagesrc = (wbNav.Document.images(4).src)
        End If
        If (StrComp(wbNav.Document.images(4).src, "/images/world/crewadv.jpg", vbTextCompare) = 0) Then
                imagesrc = (wbNav.Document.images(5).src)
        ElseIf (StrComp(wbNav.Document.images(4).src, "/images/world/mobtalk.jpg", vbTextCompare) = 0) Then
                imagesrc = (wbNav.Document.images(5).src)
        End If
        imagesrc = Replace(imagesrc, GAME +"/world/map/", "/world.php?room=")
        imagesrc = Replace(imagesrc, ".png", "")
        For karaOke = 0 To lstRoutine.ListCount
            If (StrComp(imagesrc, lstRoutine.List(karaOke)) = 0) Then
                pickle = karaOke
                karaOke = lstRoutine.ListCount + 21
            End If
        Next karaOke
    End If
    errorYes = False
    tmrInterval.Enabled = True
    End Function
    The reason for all the checks of images is the number of images varies depending on the page. Is there an easier way to find the image I want? (I grab the image since its name=the room number I'm in. then I search the listbox for that and tell the program that's where it is.
    Last edited by theuberferret; May 11th, 2007 at 01:34 PM.

  2. #2
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: Help me optimize this?

    If you want to debug for errors, you might want to get rid of On Error Resume Next so you can see if some other errors arise, ie. make sure the error isn't an error that you've made silent by using On Error Resume Next. At the moment you can't be 100% sure that the error is generated by a server lag.

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2007
    Posts
    9

    Re: Help me optimize this?

    actually an earlier version of this didn't use that. I'm positive tis server lag. The game experiences random lag spikes.

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