PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
VS 2012 [RESOLVED] If text has been found in WebBrowser1 then GoTo... , if hasn't then continue queue-VBForums
Results 1 to 2 of 2

Thread: [RESOLVED] If text has been found in WebBrowser1 then GoTo... , if hasn't then continue queue

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2012
    Posts
    51

    Resolved [RESOLVED] If text has been found in WebBrowser1 then GoTo... , if hasn't then continue queue

    Hi everyone,

    I want my program to check if "<div class="error_box"> Please try later. </div>" element has been found in WebBrowser1, if it has been found then "GoTo eend", if hasn't been found then "Application.DoEvents()".

    This is my script, but it doesn't work as I desired:
    Code:
            If WebBrowser1.Document.GetElementById("error_box").InnerText Then
                GoTo eend
            Else
                Application.DoEvents()
            End If
    Thanks for help, I give reputation as always

  2. #2
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    1,946

    Re: If text has been found in WebBrowser1 then GoTo... , if hasn't then continue queu

    Hi,

    Use Html.GetAttribute() instead of GetElementById() to check the classname attribute. See sample code provided by MSDN documentation.
    MSDN
    HtmlElement.GetAttribute Method (String)


    VB.NET Code:
    1. If (WebBrowser1.Document IsNot Nothing) Then
    2.     Dim Elems As HtmlElementCollection
    3.     Dim WebOC as WebBrowser = WebBrowser1
    4.  
    5.     Elems = WebOC.Document.GetElementsByTagName("div")
    6.  
    7.     For Each elem As HtmlElement In Elems
    8.         Dim NameStr As String = elem.GetAttribute("className")
    9.  
    10.         If ((NameStr IsNot Nothing) And (NameStr.Length <> 0)) Then
    11.             If NameStr.ToLower().Equals("error_box") Then
    12.                 GoTo eend
    13.             Else
    14.                'Application.DoEvents()
    15.             End If
    16.         End If
    17.     Next
    18. End If

    Regards,

    - kgc
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal |Programming | GitHub
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

Tags for this Thread

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width