hi .
i have these codes :

Private Sub Form_Load()
 WebBrowser1.Navigate ""

 Do Until WebBrowser1.ReadyState = READYSTATE_COMPLETE
    DoEvents
Loop
If URL = "" Then

WebBrowser1.Navigate ""

End If
End Sub

can anyone help me about how to add if webbrowser url is exact url that i want ?
or maybe help about search text in content of that url and do msgbox ?

thanks

Dani AI

Generated

A few focused notes for (and thanks to for the Timer idea): the Timer hack can work, but an event-driven approach is safer and less error-prone. Wait for the browser's DocumentComplete/NavigateComplete event, then (1) normalize the LocationURL before comparing and (2) inspect the DOM text or specific elements to detect a successful login rather than relying on an exact string match.

Example (VB6-style) — run this after the page finishes loading:

Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    Dim cur As String
    On Error Resume Next
    cur = LCase$(Trim$(WebBrowser1.LocationURL))
    cur = RemoveTrailingSlash(cur)

    ' simple exact-match example (use your site's host/path)
    If cur = "https://example.com/wp-admin" Then
        WebBrowser1.Navigate "https://example.com/wp-admin/post-new.php"
        Exit Sub
    End If

    ' search page text for a login-specific word (case-insensitive)
    Dim bodyText As String
    bodyText = LCase$(WebBrowser1.Document.Body.innerText)
    If InStr(bodyText, "logout") > 0 Or InStr(bodyText, "dashboard") > 0 Then
        MsgBox "Detected admin UI — proceed to create post"
    End If
End Sub

Private Function RemoveTrailingSlash(s As String) As String
    If Right$(s, 1) = "/" Then RemoveTrailingSlash = Left$(s, Len(s) - 1) Else RemoveTrailingSlash = s
End Function

Troubleshooting and best practices:

  • Normalize the URL (lowercase, remove trailing slash) or use substring checks (InStr) so small redirects or trailing slashes don't break detection.
  • Check the DOM for admin-only elements (a logout link, an admin bar element, or a known element id) rather than only the URL.
  • Handle errors: Document may be Nothing for frame-heavy pages or when scripts block; guard with On Error and null checks.
  • For robust automation (and to actually create posts) prefer the server APIs (WordPress REST or XML-RPC) with proper credentials instead of UI automation. Also consider moving from the old WebBrowser control to a modern engine (WebView2) if the site uses modern TLS/JS and fails to load correctly.

This keeps the logic event-driven, resilient to small redirects, and easier to debug than a tight Timer loop.

any help ?

Not really sure what you are trying to do, can you try to explain it again please? :)

From what I can see, you want to see if the person logged into the form load website, and if they logged in, they get sent to the post new page with no clicks, right?

i want program to write new post !
if login in site go to new post page !

Hey buddy, okay I made this quickly to help you out, I added webbrowser1 and a Timer with an interval of 1, and enabled. If you change the websites I used into the ones you need, it should work :) Try it out

Private Sub Form_Load()
Timer1.enabled = True
Timer1.interval = 1
WebBrowser1.Navigate ""
End Sub

Private Sub Timer1_Timer()
'If this is the successful login page, then it shows a Msgbox and navigates to next page you need.
If WebBrowser1.LocationURL = "https://www.pizzahut.co.uk/menu/pizza" Then
MsgBox "Welcome, navigating to new post screen", vbOKOnly
'The webpage you want them to be on :)
WebBrowser1.Navigate "http://www.google.com"
End If
End Sub

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.