Solved

Vb.Net equivalent of VB6 HTMLElement.Click

Posted on 2014-01-09
10
649 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
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…

809 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