Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7307871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T23:28:50+00:00 2026-05-28T23:28:50+00:00

Below is is an HTML form and below that, is a vb procedure, LoginExamp

  • 0

Below is is an HTML form and below that, is a vb procedure, “LoginExamp” that enters in the username and password. I am unable to locate the button however and click it since it does not seem to show up as a mshtml.HTMLInputElement. “htmlInput.click()” never runs. How can I adjust the loginExamp code so that the button is clicked. Thanks for any help.

<form id="loginform" name="loginform" method="post" action="">
<input id="username" class="formfield" type="text" value="User Name" maxlength="40" name="Xusername">
<input id="password" class="formfield" type="password" onfocus="clearDefault(this)" maxlength="40" name="Xpassword">
<button class="subButton" onclick="javascript: submitform()">submit!</button>
</form>

With the below code

Public Sub loginExamp()
    Dim objIE As SHDocVw.InternetExplorer
    Dim htmlDoc As mshtml.HTMLDocument
    Dim htmlInput As mshtml.HTMLInputElement
    Dim htmlColl As mshtml.IHTMLElementCollection
    Dim url As Object
    url = "http://localhost/ButtonClickTest.html" 'just a test page with the loginform above
    objIE = New SHDocVw.InternetExplorer
    With objIE
        .Navigate(url)
        .Visible = True
        While .Busy = True
            Threading.Thread.Sleep(2000)
        End While
        htmlDoc = .Document
        htmlColl = htmlDoc.getElementsByTagName("INPUT")
        While .Busy = True
            Threading.Thread.Sleep(2000)
        End While
        For Each htmlInput In htmlColl
            If htmlInput.name = "Xusername" Then
                htmlInput.value = "theusername" 'this works
            ElseIf htmlInput.name = "Xpassword" Then
                htmlInput.value = "thepassword" 'This works too
            End If
            If htmlInput.className = "subButton" Then 'This is never true
                htmlInput.click() 'This line never runs
            End If
        Next htmlInput
    End With
End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T23:28:51+00:00Added an answer on May 28, 2026 at 11:28 pm

    I was able to finally figure out the answer to my own question. Below is the code that works. Both the username and password is entered and also the button is clicked.

    Public Sub loginExamp()
        Dim objIE As SHDocVw.InternetExplorer
        Dim htmlDoc As mshtml.HTMLDocument
        Dim htmlInput As Object
        Dim url As String
        url = "http://localhost/N1/ButtonClickTest.html"'test page with the loginform above
        objIE = New SHDocVw.InternetExplorer
        With objIE
            .Navigate(url)
            .Visible = True
            While .Busy = True
                Threading.Thread.Sleep(2000)
            End While
            htmlDoc = .Document
            Dim htmlColl As mshtml.HTMLFormElement = DirectCast(htmlDoc.forms.item("loginform"), mshtml.HTMLFormElement)
            While .Busy = True
                Threading.Thread.Sleep(2000)
            End While
            For Each htmlInput In htmlColl
                If htmlInput.name = "Xusername" Then
                    htmlInput.value = "theusername"
                ElseIf htmlInput.name = "Xpassword" Then
                    htmlInput.value = "thepassword"
                End If
                If htmlInput.className = "subButton" Then
                    htmlInput.click()
                End If
            Next htmlInput
        End With
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bit of code below that creates a button on a html
I have a html form that is basically vertical but i really have no
Thank you for reading. I'm trying to create a HTML form so that my
Please see the form HTML code below <form method=post action=register> <div class=email> Email <input
I have 3 HTML form inputs fields that is dynamically generated by a add
Below is the code of a Form that I am creating. The CSS code
To dynamically fill DropDown controls on my HTML Form, I have written code that
I have a form that is generated when a user clicks a button, and
I have a button on a form that is dynamically spawning a select list,
I have a basic HTML form that gets inserted into a server side div

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.