Go Back   CodingForums.com > :: Computing & Sciences > Computer Programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-20-2012, 12:32 AM   PM User | #1
Crysis_2
New to the CF scene

 
Join Date: Aug 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Crysis_2 is an unknown quantity at this point
VB.NET Error...

Hi guys, I am writing a VB.NET here shows me the following error when I click the button btnStart:

There is Form Code:
Code:
Public Class MainForm

    Public A As New GlassLib.WebTrack

    Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        A.Interval = 6000
        A.Browser = WebBrowser
        A.Link = "http://example.com/"
        A.Word = "Nikname"
    End Sub

    Private Sub btnStart_Click(sender As Object, e As EventArgs) Handles btnStart.Click
        A.StartTrack()
    End Sub

    Private Sub btnStop_Click(sender As Object, e As EventArgs) Handles btnStop.Click
        A.StopTrack()
    End Sub
End Class
There is the class:
Code:
Public Class WebTrack

    Public Interval As Integer = 10000
    Public Link As String
    Public Word As String
    Public Browser As System.Windows.Forms.WebBrowser

    Private WithEvents TMR1 As New System.Windows.Forms.Timer()
    Private WithEvents TMR2 As New System.Windows.Forms.Timer()

    Public Sub StartTrack()
        TMR1.Interval = Interval
        TMR2.Interval = 200
        TMR1.Start()
    End Sub

    Public Sub StopTrack()
        TMR1.Stop()
    End Sub

 
    Private _IsThere As Boolean = False

    Private Sub _TMR1_Tick() Handles TMR1.Tick
        Browser.Navigate(Link)
        TMR2.Start()
    End Sub

    Private Sub _TMR2_Tick() Handles TMR2.Tick
        If Browser.DocumentText <> Nothing Then
            If _StringNumber(Browser.DocumentText, Word) > 0 Then
                If _IsThere = False Then
                    MsgBox("Online!", MsgBoxStyle.Exclamation, "Online!")
                    _IsThere = True
                End If
            Else
                _IsThere = False
            End If
            TMR2.Stop()
        End If
    End Sub

    Private Function _StringNumber(BText, LText)
        Return System.Text.RegularExpressions.Regex.Matches(BText, System.Text.RegularExpressions.Regex.Escape(LText)).Count
    End Function

End Class
Please, help me!

Last edited by Crysis_2; 08-20-2012 at 12:38 AM..
Crysis_2 is offline   Reply With Quote
Old 08-20-2012, 01:30 PM   PM User | #2
alykins
Senior Coder

 
alykins's Avatar
 
Join Date: Apr 2011
Posts: 1,608
Thanks: 37
Thanked 183 Times in 182 Posts
alykins will become famous soon enough
There has to be missing pieces to this code... first i am assuming that you are using a form since these are in there...
Code:
Public Browser As System.Windows.Forms.WebBrowser
Private WithEvents TMR1 As New System.Windows.Forms.Timer()
Private WithEvents TMR2 As New System.Windows.Forms.Timer()
MsgBox("Online!", MsgBoxStyle.Exclamation, "Online!")
so i made a simple form to help you debug.
This line is invalid and won't compile...
Code:
    Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        A.Interval = 6000
        A.Browser = WebBrowser 'I have to comment this out to get it to compile
        A.Link = "http://example.com/"
        A.Word = "Nikname"
    End Sub
after that nothing breaks... it doesn't really do anything, but it doesn't break either. can you send me all the code or post all the code here?
__________________

I code C hash-tag .Net
Reference: W3C W3CWiki .Net Lib
Validate: html CSS
Debug: Chrome FireFox IE
alykins is offline   Reply With Quote
Old 08-20-2012, 02:04 PM   PM User | #3
Crysis_2
New to the CF scene

 
Join Date: Aug 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Crysis_2 is an unknown quantity at this point
I put the class in the same namespace and everything is fine. Thanks for the help!
Crysis_2 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:17 AM.


Advertisement
Log in to turn off these ads.