Solved

Visual Basic 2010 express database and webbrowser control for auto form filling

Posted on 2011-03-07
31
2,272 Views
Last Modified: 2012-05-11
Hi,I am a complete newbie.
I want to be able to allow a user to create,edit and load profiles (loading should be from a combobox,which the user would have already created and given it a name)from a database
To keep it simple for now
we will only use 5 fields
projectname:
username:
password:
email address:
sites created?Yes/No (user cannot change this through the program only the program can)

when the user creates a profile it saves, and the user can then load it, the project name that is loaded must be shown at the top to say that this is the project currently loaded.
if possible when a new profile is created it should be loaded automatically.
These values must also be loaded onto something like Me.PasswordTextBox.Text (this textbox has to change when the new profile is loaded/created)
-----
ok now onto the next part after the user has loaded a profile, they can now register to some sites, for simplicity we will not allow the selection of sites to register to(if is simple then please go ahead and teach me checkboxes selection would be fine)
so the user clicks the register to sites button, this contains a webbrowser control.

I have some code that someone else gave me and understand what it does,but i do not know how to implement it.
I know for example if the field name was different then the elementid would change
the example below is for articledashboard.com/signup.php:

WebBrowser1.Document.GetElementById("f_emailaddress").SetAttribute("value", Me.EmailTextBox.Text)
WebBrowser1.Document.GetElementById("f_reemailaddress").SetAttribute("value", Me.EmailTextBox.Text)
WebBrowser1.Document.GetElementById("f_password").SetAttribute("value", Me.PasswordTextBox.Text)
WebBrowser1.Document.GetElementById("f_repassword").SetAttribute("value", Me.PasswordTextBox.Text)
WebBrowser1.Document.GetElementById("terms").SetAttribute("checked", True)
WebBrowser1.Document.GetElementById("sumbit").InvokeMember("click")

Ok my question is how do i create the profile creation/load/edit/save bit, and store these values in ie.Me.EmailTextBox.Text when a profile is loaded,
and then how do i implement the above code into the webbrowser control to signup to multiple sites.

example
i want it to browse to example1.com and then do the below

WebBrowser1.Document.GetElementById("f_emailaddress").SetAttribute("value", Me.EmailTextBox.Text)
WebBrowser1.Document.GetElementById("f_reemailaddress").SetAttribute("value", Me.EmailTextBox.Text)
WebBrowser1.Document.GetElementById("f_password").SetAttribute("value", Me.PasswordTextBox.Text)
WebBrowser1.Document.GetElementById("f_repassword").SetAttribute("value", Me.PasswordTextBox.Text)
WebBrowser1.Document.GetElementById("terms").SetAttribute("checked", True)
WebBrowser1.Document.GetElementById("sumbit").InvokeMember("click")

then i want to go to example2.com where the field names/elementid's are different and do the below

WebBrowser1.Document.GetElementById("f_emailaddress2").SetAttribute("value", Me.EmailTextBox.Text)
WebBrowser1.Document.GetElementById("f_reemailaddress2").SetAttribute("value", Me.EmailTextBox.Text)
WebBrowser1.Document.GetElementById("f_password2").SetAttribute("value", Me.PasswordTextBox.Text)
WebBrowser1.Document.GetElementById("f_repassword2").SetAttribute("value", Me.PasswordTextBox.Text)
WebBrowser1.Document.GetElementById("terms2").SetAttribute("checked", True)
WebBrowser1.Document.GetElementById("sumbit").InvokeMember("click")

After the creation of sites is done it must update the field of sites created to yes


I also heard about something like documentcomplete or something dont really know what.
0
Comment
Question by:alphaleads
  • 17
  • 14
31 Comments
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
When working with the WebBrowser control, and the Document, the DocumentComplete event is a good place to start.  That event ensures that you have fully downloaded the document, and are ready to process.  Otherwise, you could have a condition where the Document property is not valid.
0
 

Author Comment

by:alphaleads
Comment Utility
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        WebBrowser1.Navigate("http://www.articledashboard.com/signup.php")
        WebBrowser1.Document.GetElementById("f_emailaddress").SetAttribute("value", "test")
        WebBrowser1.Document.GetElementById("f_reemailaddress").SetAttribute("value", "test")
        WebBrowser1.Document.GetElementById("f_password").SetAttribute("value", "test")
        WebBrowser1.Document.GetElementById("f_repassword").SetAttribute("value", "test")
        WebBrowser1.Document.GetElementById("terms").SetAttribute("checked", True)

where would i add the document complete code code? and if it doesnt load in 30 seconds then skip?
0
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
If you select the WebBrowser control in the IDE, and switch to the Events view (lightning bolt icon in the Properties Grid).  Find the DocumentCompleted event, and double-click in the empty space in column #2.  The IDE will create a new event handler for you.

    
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted

End Sub

Open in new window


Then, you just need to move the code, after the navigate call, to the DocumentCompleted event handler.
Screenshot.png
0
 

Author Comment

by:alphaleads
Comment Utility
How do i implement this, as i have multiple sites to sign up to,
i want it to browse to example1.com and then do the below

WebBrowser1.Document.GetElementById("f_emailaddress").SetAttribute("value", Me.EmailTextBox.Text)
WebBrowser1.Document.GetElementById("f_reemailaddress").SetAttribute("value", Me.EmailTextBox.Text)
WebBrowser1.Document.GetElementById("f_password").SetAttribute("value", Me.PasswordTextBox.Text)
WebBrowser1.Document.GetElementById("f_repassword").SetAttribute("value", Me.PasswordTextBox.Text)
WebBrowser1.Document.GetElementById("terms").SetAttribute("checked", True)
WebBrowser1.Document.GetElementById("sumbit").InvokeMember("click")

then i want to go to example2.com where the field names/elementid's are different and do the below

WebBrowser1.Document.GetElementById("f_emailaddress2").SetAttribute("value", Me.EmailTextBox.Text)
WebBrowser1.Document.GetElementById("f_reemailaddress2").SetAttribute("value", Me.EmailTextBox.Text)
WebBrowser1.Document.GetElementById("f_password2").SetAttribute("value", Me.PasswordTextBox.Text)
WebBrowser1.Document.GetElementById("f_repassword2").SetAttribute("value", Me.PasswordTextBox.Text)
WebBrowser1.Document.GetElementById("terms2").SetAttribute("checked", True)
WebBrowser1.Document.GetElementById("sumbit").InvokeMember("click")

So this must actually do it for multiple sites:
to continue currently i have the code for one site:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        WebBrowser1.Navigate("http://www.articledashboard.com/signup.php")
        WebBrowser1.Document.GetElementById("f_emailaddress").SetAttribute("value", "test")
        WebBrowser1.Document.GetElementById("f_reemailaddress").SetAttribute("value", "test")
        WebBrowser1.Document.GetElementById("f_password").SetAttribute("value", "test")
        WebBrowser1.Document.GetElementById("f_repassword").SetAttribute("value", "test")
        WebBrowser1.Document.GetElementById("terms").SetAttribute("checked", True)

where would i put the document complete code on it? because different sites have different structures therefore i cannot use one instance of document complete
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
Comment Utility
If there is a difference in the two URLs, then you can have multiple methods, and decide which method based on the URL from the WebBrowserDocumentCompletedEventArgs.

WebBrowserDocumentCompletedEventArgs.Url Property
http://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowserdocumentcompletedeventargs.url.aspx

Private Sub WebBrowser1_DocumentCompleted(sender as Object, e as WebBrowserDocumentCompletedEventArgs) _ 
     Handles WebBrowser1.DocumentCompleted

    Dim messageBoxVB as New System.Text.StringBuilder()
    messageBoxVB.AppendFormat("{0} = {1}", "Url", e.Url)
    messageBoxVB.AppendLine()
    MessageBox.Show(messageBoxVB.ToString(),"DocumentCompleted Event")

End Sub

Open in new window

0
 

Author Comment

by:alphaleads
Comment Utility
I really don't understand what you  mean sorry to be a pain i have completed the first site like this:
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        WebBrowser1.Navigate("http://www.articledashboard.com/signup.php")
        
    End Sub


    Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted

        WebBrowser1.Document.GetElementById("f_emailaddress").SetAttribute("value", "test")
        WebBrowser1.Document.GetElementById("f_reemailaddress").SetAttribute("value", "test")
        WebBrowser1.Document.GetElementById("f_password").SetAttribute("value", "test")
        WebBrowser1.Document.GetElementById("f_repassword").SetAttribute("value", "test")
        WebBrowser1.Document.GetElementById("terms").SetAttribute("checked", True)
    End Sub
End Class

Open in new window


Where do i go from here?
0
 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 500 total points
Comment Utility
A simple If...Then block would be one way, but a Select...End Select block is another.  

Example:

If e.Url = "Web Site 1 address" Then
    Me.ProcessWebSite1()
Else If e.Url = "Web Site 2 address" Then
    Me.ProcessWebSite2()
End If

Open in new window


If you find yourself with a lot of web sites, then there will be a better approach than what I described, but let's start with the easy-to-understand solution first.
0
 

Author Comment

by:alphaleads
Comment Utility
do you have skype or msn? I would pay you for your time
0
 

Author Comment

by:alphaleads
Comment Utility
because there is alot of websites not just 2
0
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
No, I prefer the free approach, since it is isn't that much time investment.  I am usually a busy, busy camper *BIG GRIN*.  This way, I can decide when I have time...
0
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
Are there different element IDs for each web site, or do they follow a pattern?

Example:

#1
-----------------
f_emailaddress
f_reemailaddress
f_password
f_repassword
terms
sumbit

#2
-----------------
f_emailaddress2
f_reemailaddress2
f_password2
f_repassword2
terms
sumbit

#3
-----------------
f_emailaddress3
f_reemailaddress3
f_password3
f_repassword3
terms
sumbit



0
 

Author Comment

by:alphaleads
Comment Utility
say if i where to try to load the urls for signup from within a text file? and loop it until it reached the bottom of the text file, would that not be easier?
 I could also include all of the elementids within the same documentcomplete function im guessing? since if one element id doesnt exist on a page it will ignore it? Correct me if i am wrong?
If i where to do this how would i go about doing it?
0
 

Author Comment

by:alphaleads
Comment Utility
there are differrent elemement ids' on different websites, and some require a form submit button which then leads to another form and another submit button
0
 

Author Comment

by:alphaleads
Comment Utility
i need to get this done by the 14th, if i cant i fail my degree :( im gobsmacked i hired a tutor and he ran off with my money
0
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
The "best" choice really depends on what you are working with exactly.  This is starting to sound like a refactoring question.  Refactoring code is a disciplined process that can lead to better, easier to understand code.  You need to look for patterns in the code you have to find ways to improve it.

Code refactoring
http://en.wikipedia.org/wiki/Code_refactoring

I don't quite get the exact picture, from a 10000-meter view.  

1) Do you have control over the content of the web site?  

2) Do the pages have the similar elements?
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:alphaleads
Comment Utility
1) I do not have control over the websites
2) They are all pages to signup to, so the minimum they contain is email,password,accept terms,submit.
The maximum they contain is stuff like nickname,address,first name, last name, (in some cases full name, so we can concatenate this field, im guessing)

I have some other code which i wrote don't know if it works though it uses command buttons.

Example:
After the register button is clicked:
WebBrowser1.Document.GetElementById("f_emailaddress").SetAttribute("value", Me.EmailTextBox.Text)
 WebBrowser1.Document.GetElementById("f_reemailaddress").SetAttribute("value", Me.EmailTextBox.Text)
 WebBrowser1.Document.GetElementById("f_password").SetAttribute("value", Me.PasswordTextBox.Text)
 WebBrowser1.Document.GetElementById("f_repassword").SetAttribute("value", Me.PasswordTextBox.Text)
 WebBrowser1.Document.GetElementById("terms").SetAttribute("checked", True)
 WebBrowser1.Document.GetElementById("sumbit").InvokeMember("click")

Open in new window

This should update the field of sites created to yes:
A message box pops up saying sites have been registered to, please wait an hour and check your email and click the verification links.

After they have clicked on the verification links, they can now click on the second button which does the following:
and if sites created is=yes then allow the below code, else message box saying sites havent been created yet

Navigate to http://www.articledashboard.com/login.php

WebBrowser1.Document.GetElementById("f_emailaddress").SetAttribute("value", Me.EmailTextBox.Text)
WebBrowser1.Document.GetElementById("f_password").SetAttribute("value", Me.PasswordTextBox.Text)
WebBrowser1.Document.GetElementById("sumbit").InvokeMember("click")

after document has loaded

navigate to http://www.articledashboard.com/penname.php

WebBrowser1.Document.GetElementById("f_penname").SetAttribute("value", Me.UsernameTextBox.Text)
WebBrowser1.Document.GetElementById("sumbit").InvokeMember("click")

Open in new window

Then it should update the database field of sites verified to yes

The third button they click is the submission button
If sites verified is yes then allow the below, else message box sites havent been verfied please verify.

to submit article
Navigate to http://www.articledashboard.com/login.php
WebBrowser1.Document.GetElementById("f_emailaddress").SetAttribute("value", Me.EmailTextBox.Text)
WebBrowser1.Document.GetElementById("f_password").SetAttribute("value", Me.PasswordTextBox.Text)
WebBrowser1.Document.GetElementById("sumbit").InvokeMember("click")

after document has loaded
navigate to http://www.articledashboard.com/submitarticles.php
WebBrowser1.Document.GetElementById("f_pennameid").SetAttribute("value", Me.UsernameTextBox.Text)
WebBrowser1.Document.GetElementById("f_categoryid").SetAttribute("value", Me.ArticleCategoryComboBox.Text)
WebBrowser1.Document.GetElementById("f_arttitle").SetAttribute("value", Me.ArticleTitleTextBox.Text)
WebBrowser1.Document.GetElementById("f_artsummary").SetAttribute("value", Me.ArticleSummaryTextBox.Text)
WebBrowser1.Document.GetElementById("f_artbody").SetAttribute("value", Me.ArticleBodyTextBox.Text)
WebBrowser1.Document.GetElementById("f_artres").SetAttribute("value", Me.ArticleResourceTextBox.Text)
WebBrowser1.Document.GetElementById("f_artkey").SetAttribute("value", Me.ArticleKeywordsTextBox.Text)
WebBrowser1.Document.GetElementById("sumbit").InvokeMember("click")

after document has loaded
http://www.articledashboard.com/logout.php

Open in new window


Alot of sites have different element ids, and im sure you can understand the whole procedure now.
0
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
The EE membership guidelines dictate a strict "code of ethics" for working with academic-based questions, to prevent the expert from answering questions directly.  Once that condition is established, there is a limiting factor to the type of help that I can provide.  Fortunately, for me, that corresponds with the way to I choose to do business with everyone.  I believe that there is a value in doing something for yourself, and there a valuable lessons that come from struggling and failing, and then learning the correct approach.  I learn more from my mistakes than I do my successes.

With that said, your approach of a text file containing the web site information is a sound approach.  A CSV file is a good choice for the file.

VB.NET: How to read a CSV file into an array
http://www.fryan0911.com/2009/05/vbnet-how-to-read-csv-file-into-array.html


Private Sub ReadCSVFileToArray()
Dim strfilename As String
Dim num_rows As Long
Dim num_cols As Long
Dim x As Integer
Dim y As Integer
Dim strarray(1, 1) As String

' Load the file.
strfilename = "test.csv"

'Check if file exist
If File.Exists(strfilename) Then
Dim tmpstream As StreamReader = File.OpenText(strfilename)
Dim strlines() As String
Dim strline() As String

'Load content of file to strLines array
strlines = tmpstream.ReadToEnd().Split(Environment.NewLine)

' Redimension the array.
num_rows = UBound(strlines)
strline = strlines(0).Split(",")
num_cols = UBound(strline)
ReDim strarray(num_rows, num_cols)

' Copy the data into the array.
For x = 0 To num_rows
strline = strlines(x).Split(",")
For y = 0 To num_cols
strarray(x, y) = strline(y)
Next
Next

' Display the data in textbox
For x = 0 To num_rows
For y = 0 To num_cols
TextBox1.Text = TextBox1.Text & strarray(x, y) & ","
Next
TextBox1.Text = TextBox1.Text & Environment.NewLine
Next

End If

End Sub

Open in new window

0
 

Author Comment

by:alphaleads
Comment Utility
so basically all in all, its a program which allows a user to
1)create/load/edit a profile
2)signup to pages using the profile data
3)verify sites
4)submit to sites

The sites can have different procedures for either steps number 2,3 or 4. All i need to know is how to do two sites with different procedures and different element ids with the above code.
0
 

Author Comment

by:alphaleads
Comment Utility
My project is research based, it's regarding SEO. The programming is the design and build part but i have stated i have no porgramming knowledge in my project definition document, they said thats fine, i have also said i will hire a tutor for help. But the tutor ran away.
0
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
My friend, I totally feel your pain, but unfortunately that doesn't change the situation from my perspective.  I will try to help you where I can...
0
 

Author Comment

by:alphaleads
Comment Utility
Thanks, but  can you read the comment i made at 08/03/11 09:32 AM, ID: 35071604, please and like i said i can just hard code it all into the app,each step by step, yes the code will be bulky but it will work. I just need to know how to navigate to site 1, fill up a form, navigate to site 2 fill up a differnt form etc.
0
 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 500 total points
Comment Utility
Here is the problem, as I see it:  If you want to be able to process different web sites with a single DocumentCompleted event handler, then you need to detect which web site you are working with.  

Steps:

1) Navigate to a web page

2) Handle the DocumentCompleted event

3) Check the e.Url value

4) Go to the appropriate method to set the appropriate element values, and click the <Submit> button

5) Navigate to the next web page

6) Repeat steps 2 - 5
0
 

Author Comment

by:alphaleads
Comment Utility
:) let me try that, might take me a bit of time, where do i place the method? and can u give me an example of steps 2 to 5 with 3 differnt sites? say example1.com, example2.com, example3.com/

  WebBrowser1.Navigate("example1.com")
and it must have this after document complete
 WebBrowser1.Document.GetElementById("f_emailaddress").SetAttribute("value", "test")
WebBrowser1.Document.GetElementById("sumbit").InvokeMember("click")

  WebBrowser1.Navigate("example2.com")
and it must have this after document complete
 WebBrowser1.Document.GetElementById("f_emailaddress2").SetAttribute("value", "test")
WebBrowser1.Document.GetElementById("sumbit").InvokeMember("click")

Method 3 is the complicated one


  WebBrowser1.Navigate("example3.com")
and it must have this after document complete
 WebBrowser1.Document.GetElementById("f_emailaddress3").SetAttribute("value", "test")
WebBrowser1.Document.GetElementById("sumbit").InvokeMember("click")
After this the webbrowser must be ready again
 WebBrowser1.Navigate("example3.com/submit.php")
After this the webbrowser must be ready again
 WebBrowser1.Document.GetElementById("name").SetAttribute("value", "test")









0
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
Event handlers, methods, properties, etc., can all go in the same .vb file for the form.  If you want to add a method to your code, just go to the bottom of the file, and add the method before the End Class marker.  

Your question has many complicated moving parts.  The problem with the DocumentCompleted event handler is determining where you are in the process.  When you click the <Submit> button, the page will perform a post-back (a common term in web programming).  This will fire the DocumentCompleted event, and your code will not be able to determine whether this was the first time that you came to this web page, or the subsequent time.  

Here are some examples of methods using your code.  The problem with this approach is timing.  You would be trying to click on the <Submit> button, and it will fire another DocumentCompleted event, and your code will also be trying to navigate to the next page.  This is an inherent problem with asynchronous programming, where you can't be sure of the order of operations.  Synchronous programming forces the application to wait for something to complete, before continuing on with the next process.

Private Sub ProcessWebSite1()
    WebBrowser1.Document.GetElementById("f_emailaddress").SetAttribute("value", "test")
    WebBrowser1.Document.GetElementById("sumbit").InvokeMember("click")
    WebBrowser1.Navigate("example2.com")
End Sub

Open in new window


Private Sub ProcessWebSite2()
    WebBrowser1.Document.GetElementById("f_emailaddress2").SetAttribute("value", "test")
    WebBrowser1.Document.GetElementById("sumbit").InvokeMember("click")
    WebBrowser1.Navigate("example3.com")
End Sub

Open in new window


Here is an article that has a discussion that highlights this point.

C# how to wait for a webpage to finish loading before continuing
http://stackoverflow.com/questions/583897/c-how-to-wait-for-a-webpage-to-finish-loading-before-continuing

Me.WebBrowser1.Navigate(url)
While Me.WebBrowser1.ReadyState <> WebBrowserReadyState.Complete
   Application.DoEvents()
End While

Open in new window

0
 

Author Comment

by:alphaleads
Comment Utility
if i try
If e.Url = "Web Site 1 address" Then
    Me.ProcessWebSite1()
Else If e.Url = "Web Site 2 address" Then
    Me.ProcessWebSite2()
End If

Open in new window



it gives
Error      1      Overload resolution failed because no accessible '=' can be called with these arguments:
    'Public Shared Operator =(a As String, b As String) As Boolean': Value of type 'System.Uri' cannot be converted to 'String'.
    'Public Shared Operator =(uri1 As System.Uri, uri2 As System.Uri) As Boolean': Value of type 'String' cannot be converted to 'System.Uri'.      

0
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
Sorry for the confusion, that would be e.Url.ToString(), to convert the URI to a string.
0
 

Author Comment

by:alphaleads
Comment Utility
ok, i am still heavily stuck, if i call the method depending on the url and the if then formula, it still crashes, so i decided to compile it just on its own so it just logs in:

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Navigate("http://www.articledashboard.com/login.php")


        

    End Sub

    Private Sub Browser_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
            WebBrowser1.Document.GetElementById("f_username").SetAttribute("value", "myusername")
            WebBrowser1.Document.GetElementById("f_password").SetAttribute("value", "mypassword")
            WebBrowser1.Document.GetElementById("B7").InvokeMember("click")
    End Sub
End Class

Open in new window


This still crashes after submitting the form any idea as to why?
0
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
I don't understand what you mean by "crashes".  Are you saying that the developer environment (IDE) crashes?  Or, are you referring to your application?  Is there an error associated with this problem?
0
 

Author Comment

by:alphaleads
Comment Utility
When i run the app it gives A first chance exception of type 'System.NullReferenceException' occurred in WindowsApplication1.exe., it says that within the ide, this ouccrs after the submit button is pressed, and as soon as the next page is loaded.
0
 

Author Comment

by:alphaleads
Comment Utility
here is the code im using again, i made a mistake while pasting the previous code.
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        WebBrowser1.Navigate("http://www.articledashboard.com/login.php")

    End Sub

    Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
        WebBrowser1.Document.GetElementById("f_username").SetAttribute("value", "myusername")
        WebBrowser1.Document.GetElementById("f_password").SetAttribute("value", "mypassword")
        WebBrowser1.Document.GetElementById("B7").InvokeMember("click")
    End Sub
End Class

Open in new window

0
 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 500 total points
Comment Utility
First chance exceptions are those types of exceptions that don't stop the application from running, and often can be ignored.

What is a First Chance Exception?
http://blogs.msdn.com/b/davidklinems/archive/2005/07/12/438061.aspx

What is a first chance exception?
When an application is being debugged, the debugger gets notified whenever an exception is encountered  At this point, the application is suspended and the debugger decides how to handle the exception. The first pass through this mechanism is called a "first chance" exception. Depending on the debugger's configuration, it will either resume the application and pass the exception on or it will leave the application suspended and enter debug mode. If the application handles the exception, it continues to run normally.

You usually get a NullReferenceException when you try to reference something that can't be found, and then try to access a member like this:

WebBrowser1.Document.GetElementById("B7") returns nothing (null)

   so

WebBrowser1.Document.GetElementById("B7").InvokeMember("click") will fail with the NullReferenceException.


0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

772 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now