Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: VB.NET Error...

  1. #1
    New to the CF scene
    Join Date
    Aug 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.

  • #2
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,758
    Thanks
    41
    Thanked 191 Times in 190 Posts
    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

  • #3
    New to the CF scene
    Join Date
    Aug 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I put the class in the same namespace and everything is fine. Thanks for the help!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •