Solved

Dot Net - webbrowser control and case select

Posted on 2009-05-19
1
369 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
ID: 24429523
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
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…

778 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