Solved

Dot Net - webbrowser control and case select

Posted on 2009-05-19
1
358 Views
Last Modified: 2013-11-26
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
Comment
Question by:NicoJuicy
1 Comment
 
LVL 7

Accepted Solution

by:
NicoJuicy earned 0 total points
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now