CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2007
    Posts
    448

    Need help with loops

    Hi guys,

    I need your help with the loop. When I load a form to set up the timer to one second, it will get access to my site via httpwebrequest. It will look for the html tags called "mystrings1" and it will look for the matches pattern in the same line as the mystrings1 tags to see if the tags has "<span mystrings2>"Enabled"", then it will display the messagebox when each matches are found.



    Code:
    Public Sub timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs)
    		timer1.Enabled = False
    		timer1.Stop()
    	
    		Dim form1 As Form1 = TryCast(Owner, Form1)
    		Try
    			Dim URL1 As String = "http://www.mysite.com/myscript.php?user=test&pass=test"
    			Dim request1 As HttpWebRequest = CType(WebRequest.Create(URL1), HttpWebRequest)
    			Dim response1 As HttpWebResponse = CType(request1.GetResponse(), HttpWebResponse)
    			Dim reader1 As New StreamReader(response1.GetResponseStream())
    			Dim str1 As String = reader1.ReadToEnd()
    			Dim pattern1 As String = "(<p\sid='mystrings1'>(?<mystrings1>[^<>]+)</p>.*<span\sid=\""test\"">Enabled"")"
    			Dim matches1 As MatchCollection = Regex.Matches(str1, pattern1)
    			Dim m1 As Match = Regex.Match(str1, pattern1)
    	
    			For Each x1 As Match In matches1
    				Dim StrArr1() As String = x1.Value.ToString().Split()
    				MessageBox.Show(x1.Groups("mystrings1").Value)
    			Next x1
    	
    		Catch ex As Exception
    		End Try
    	End Sub

    What my code are doing is when they get access to my site, they will look for the tags called "mystrings1" and it will look for the matches pattern in the same line as the mystrings1 tags to see if the tags has "<span mystrings2>"Enabled"", then it will only display the messagebox once at a time when more than one matches are found.

    I have already set the loops using with For Each x1 As Match In matches1 statement.

    Do you know why the loops isn't working and are there a way to fix the problem?

    Thanks,
    Mark

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Need help with loops

    Try 60 seconds...
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Aug 2007
    Posts
    448

    Re: Need help with loops

    I have tried it, but it will make no difference. What I am trying to do is to reads the php source from my website to see if the strings in the mystrings2 tags have got the text called "enabled"while each matches are found, then extract the strings from mystrings1 tags and display the messagebox. However, the messagebox are only displaying once when I have got more than one matches.


    Any idea how I can find the strings in the mystrings2 tags to see if each matches are found?

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Need help with loops

    Create a SERVICE that runs on your server. Send it a parameter and have it reply with Not Found, or spits back the value returned. It should be able to access the code ON the server
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured