Well this script is working partially, when the script submit the login a MsgBox("The login is wrong!") appeared, but when the page load a MsgBox("The login is ok!") appears.
Why the "The login is wrong!" is appearing? Can someone fix for me or tell me another way to do that?

Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
        If WebBrowser1.Url.AbsoluteUri = "https://steamcommunity.com/login/" Then
            WebBrowser1.Document.GetElementById("steamAccountName").SetAttribute("Value", "gogost")
            WebBrowser1.Document.GetElementById("steamPassword").SetAttribute("Value", "gogost")
            WebBrowser1.Document.Forms(1).InvokeMember("submit")


        End If


        If Me.WebBrowser1.DocumentText.Contains("LogOut") Then

            MsgBox("The login is ok!")

        Else

            MsgBox("The login is wrong!")

        End If

...Why the "The login is wrong!" is appearing?...

The reason is because you are not logged in when you first load that web-page.

See if this helps about checking if you have already attempted to Log In.

Private websiteAlreadyAccessed As Boolean = False '// determine if webpage has been accessed.

    Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
        If WebBrowser1.Url.AbsoluteUri = "https://steamcommunity.com/login/" Then
            WebBrowser1.Document.GetElementById("steamAccountName").SetAttribute("Value", "gogost")
            WebBrowser1.Document.GetElementById("steamPassword").SetAttribute("Value", "gogost")
            WebBrowser1.Document.Forms(1).InvokeMember("submit")
        End If

        If Me.WebBrowser1.DocumentText.Contains("LogOut") Then
            MsgBox("The login is ok!")
        Else
            '// check if web-page has been visited and display result if there was already an attempt to LogIn.
            If websiteAlreadyAccessed = True Then MsgBox("The login is wrong!")
        End If
        websiteAlreadyAccessed = True '// set to True once first loading the web-page.
    End Sub

Thank you very much i love you!!!
Marry with me!!! :D

Thankyou very much mannn <3 <3 <3

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.