Avatar of Jimbo99999
Jimbo99999Flag for United States of America asked on

Vb.Net equivalent of VB6 HTMLElement.Click

Good Day Experts!

Yet another first here that I hope you can help me out with.  

I converted a little VB6 project to Vb.Net(2005).  I am having trouble with some HTML in it.

Dim x As HTMLHtmlElement
Dim xc As IHTMLElementCollection
For Each x In xc
    If InStr(x.outerHTML, "Enter") > 0 Then
        Set submitElement = x
        Exit For
    End If
Next

submitElement.Click

The trouble I am having is finding the VB.Net equivalent for the .Click on submitElement.

Please ask questions as I am out of ideas after a a few hrs of trying.

Thanks,
jimbo99999
Visual Basic.NET

Avatar of undefined
Last Comment
Jimbo99999

8/22/2022 - Mon
Carl Tawn

Can you put what you are doing into context, what is it you are trying to achieve? Are you manipulating an associated web page somewhere, or is this just an arbitrary collection of elements?

I only ask because there may be a better way to achieve what you want rather than attempting a like-for-like conversion.
ASKER
Jimbo99999

Thanks for your response.  I will hope to get back to this little project this afternoon.

jimbo99999
Nasir Razzaq

Equivalent in VB.NET would be

submitElement.RaiseEvent("Click")
Your help has saved me hundreds of hours of internet surfing.
fblack61
ASKER
Jimbo99999

Hello everyone...finally able to get back on this project.

I am just trying submitElement.RaiseEvent("Click") now and am receiving an error.
"An unhandled exception of type 'System.ArgumentException' occurred in System.Windows.Forms.dll.  Additional information: Value does not fall within the expected range".

The messagebox has two button labelled <Break> and <Continue>.  My breakpoint is now green with an error in the left margin.

Any ideas? I am starting my search now.

Thanks,
jimbo99999
Nasir Razzaq

Does it work with

submitElement.RaiseEvent("click")

?
ASKER
Jimbo99999

Yes. I received the above error using it.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Nasir Razzaq

You replied "Yes" to my question "Does it work with following" but also said you received an error. So does it work or do you still receive the same error?
ASKER
Jimbo99999

I apolgize, it was late when I responded.

I receive the error using submitElement.RaiseEvent("click").

I was just trying anything I could find while searching on the net.  This is working but I don't understand why:

submitElement.InvokeMember("Click")

Thanks,
jimbo99999
ASKER CERTIFIED SOLUTION
Nasir Razzaq

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
Jimbo99999

Thanks for your efforts...they led to make that discovery soultion.

Have a good day,
jimbo99999
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy