• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 380
  • Last Modified:

Dot Net - webbrowser control and case select

I have the following code as a function (see below) for class  navhandler.

The regular expressions work for login and overview.
But they won't work for buildings and etc...

It seems that anything after overview won't work and every page i click is indentified as an overview (after i logged in).

So, login and overview works.

The rest doesn't... But i can't seem to find any mistakes in my code :s
Imports System.Text.RegularExpressions
 
 
Public Class navhandler
    Dim regexLogin As New Regex("http://www.o game.")
    Dim regexOverview As New Regex("/index.php?page=overview&session=[a-z0-9]+")
    Dim regexResources As New Regex("/index.php?page=resources&session=[a-z0-9]+&pc=1")
    Dim regexResearch As New Regex("/index.php?page=buildings&session=[a-z0-9]+&mode=Forschung")
    Dim regexShipYard As New Regex("/index.php?page=buildings&session=[a-z0-9]+&mode=Flotte")
    Dim regexFleet As New Regex("/index.php?page=flotten1&session=[a-z0-9]+&mode=Flotte")
    Dim regexTechnology As New Regex("/index.php?page=techtree&session=[a-z0-9]+")
    Dim regexGalaxy As New Regex("/index.php?page=galaxy")
    Dim regexMessages As New Regex("/index.php?page=messages&dsp=1&session=[a-z0-9]+")
    Dim regexDefence As New Regex("/index.php?page=buildings&session=[a-z0-9]+&mode=Verteidigung")
    Dim regexStatistics As New Regex("/index.php?page=statistics&session=[a-z0-9]+")
    Dim regexBuildings As New Regex("/index.php?page=b_building&session=[a-z0-9]+")
    Dim regexAlliance As New Regex("/index.php?page=allianzen&session=[a-z0-9]+")
    Dim regexSearch As New Regex("/index.php?page=suche&session=[a-z0-9]+")
    Dim regexFriendslist As New Regex("/index.php?page=buddy&session=[a-z0-9]+")
    Dim regexOptions As New Regex("/index.php?page=options&session=[a-z0-9]+")
 
    Public Function typePage() As String
        '@return: login, overview, fleet, defense, alliance, statistics,messages
        Dim typePageSTR, url As String
        Dim blnFound As Boolean = False
 
        typePageSTR = ""
        Dim wb As CustomBrowser = gameBrowser.TabControl1.SelectedTab.Tag
        'source = wb.DocumentText.ToString
        url = wb.Url.ToString
      
        If (regexLogin.Match(url).ToString <> "") Then
            OgameBrowser.lblgamePage.Text = "Detected: Dutch Login page"
            typePageSTR = "login"
            blnFound = True
        End If
        If (regexOverview.Match(url).ToString <> "") Then
            OgameBrowser.lblgamePage.Text = "Detected: Dutch Overview page"
            typePageSTR = "overview"
 
            blnFound = True
        End If
 
        If (regexBuildings.Match(url).ToString <> "") Then
            OgameBrowser.lblgamePage.Text = "Detected: Dutch Buildings page"
            typePageSTR = "buildings"
            blnFound = True
        End If
        If (regexMessages.Match(url).ToString <> "") Then
            OgameBrowser.lblgamePage.Text = "Detected: Dutch Messages page"
            typePageSTR = "messages"
            blnFound = True
        End If
       
        If blnFound = True Then
            Return typePageSTR
        Else
            Return "Page not yet detected OR it's not an game page"
        End If
 
    End Function
End Class

Open in new window

0
NicoJuicy
Asked:
NicoJuicy
1 Solution
 
NicoJuicyAuthor Commented:
I have found it.

As this is the first time i use regular exprressions, i have to unescape the dots in my urls and the quoatation marks to.

eg. "http://www\.zdnet\.be"
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now