Thread: Need help with loops

  1. #1
    Registered User
    Join Date
    Apr 2011

    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.

    System::Void timer1_Tick(System::Object^  sender, System::EventArgs^  e)
    	timer1->Enabled = false;
            String ^URL1 = "";
            HttpWebRequest ^request1 = safe_cast<HttpWebRequest^>(WebRequest::Create(URL1));
            HttpWebResponse ^response1 = safe_cast<HttpWebResponse^>(request1->GetResponse());
            StreamReader ^reader1 = gcnew StreamReader(response1->GetResponseStream());
            String ^str1 = reader1->ReadToEnd();
            String ^pattern1 = "(<p\\sid='mystrings1'>(?<mystrings1>[^<>]+)</p>.*<span id=\"mystrings2\">Enabled)";
            Regex^ r = gcnew Regex (pattern1, RegexOptions::IgnoreCase);
            MatchCollection ^matches1 = r->Matches(str1, pattern1);
            for each (Match ^x1 in matches1)
                array<String^> ^StrArr1 = x1->Value->ToString()->Split();
        catch (Exception ^ex)

    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?


  2. #2
    Registered User
    Join Date
    Jun 2005
    That code is not C++, so it is rather pointless to ask questions about it in a C++ forum.

    You would be better off directing asking your question in a .NET forum.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  3. #3
    Rat with a C++ compiler Rodaxoleaux's Avatar
    Join Date
    Sep 2011
    I think I saw this post on Hack Forums while I was trolling around for laughs. I also saw a thread that says "wher do i put semicolin?"
    How to ask smart questions
    DWORD dwBytesOverwritten;
    BYTE rgucOverWrite[] = {0xe9,0,0,0,0};

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. converting for loops to while loops
    By nabhatt in forum C Programming
    Replies: 3
    Last Post: 02-16-2012, 09:45 PM
  2. Replies: 3
    Last Post: 06-01-2011, 04:19 PM
  3. loops, menu loops
    By gloworm in forum C Programming
    Replies: 17
    Last Post: 04-12-2010, 07:59 PM
  4. For Loops!!!
    By Nailogamer in forum C++ Programming
    Replies: 5
    Last Post: 08-14-2003, 06:46 PM
  5. Loops
    By robjules in forum C++ Programming
    Replies: 7
    Last Post: 11-05-2002, 07:00 PM