...

View Full Version : VB.NET Error...



Crysis_2
08-20-2012, 12:32 AM
Hi guys, I am writing a VB.NET here shows me the following error when I click the button btnStart:
http://prikachi.com/images/138/5160138Z.png (http://prikachi.com/images/134/5160134b.png)
There is Form 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:

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! :confused:

alykins
08-20-2012, 01:30 PM
There has to be missing pieces to this code... first i am assuming that you are using a form since these are in there...


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...


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?

Crysis_2
08-20-2012, 02:04 PM
I put the class in the same namespace and everything is fine. Thanks for the help!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum