Solved

Vb.Net equivalent of VB6 HTMLElement.Click

Posted on 2014-01-09
10
657 Views
Last Modified: 2014-02-13
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
0
Comment
Question by:Jimbo99999
  • 5
  • 4
10 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 39770432
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.
0
 

Author Comment

by:Jimbo99999
ID: 39799811
Thanks for your response.  I will hope to get back to this little project this afternoon.

jimbo99999
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 39806726
Equivalent in VB.NET would be

submitElement.RaiseEvent("Click")
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:Jimbo99999
ID: 39816169
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
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 39816307
Does it work with

submitElement.RaiseEvent("click")

?
0
 

Author Comment

by:Jimbo99999
ID: 39816859
Yes. I received the above error using it.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 39817334
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?
0
 

Author Comment

by:Jimbo99999
ID: 39817668
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
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 39818274
Ah that should work. I knew there is a method which is used to raise events but told you about the wrong method.
0
 

Author Closing Comment

by:Jimbo99999
ID: 39856972
Thanks for your efforts...they led to make that discovery soultion.

Have a good day,
jimbo99999
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question