Solved

Close a windows form from its own "MyBase.Load" Event

Posted on 2004-08-13
4
587 Views
Last Modified: 2008-03-17
Hi,

I'm trying to create a program that will open, perform a task and then close automatically. Here's the program...

'***************************
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        With Me.AxWebBrowser1
            .Navigate("http://sample.website.com/")

            Do
                Application.DoEvents()
            Loop While AxWebBrowser1.Busy

            '--Load username and password and submit the form
            .Document.myForm._email.value = "user@email.com"
            .Document.myForm._pass.value = "pass"
            .Document.myForm.submit()
            Do
                Application.DoEvents()
            Loop While AxWebBrowser1.Busy

       End With

       Me.Close

End Sub
'***************************

When the program tries closing the form at the end it results in a error: Cannot access a disposed object named "Form2"

Does anyone know how to achieve what I want to do without getting this error.

Thanks a lot for any help!
0
Comment
Question by:siono4
  • 2
4 Comments
 
LVL 14

Expert Comment

by:Matti
ID: 11791673
Hi!

Try
Unload me

Matti
0
 

Author Comment

by:siono4
ID: 11791825
Hello Matti,

Nice idea but unfortunately doesn't work because when I use "Me" it refers to the windows form and I get the error:
Value of type 'Form2' cannot be converted to 'System.AppDomain'.

Maybe it's possible to unload the application domain but I don't know how to do this...
0
 
LVL 4

Accepted Solution

by:
hamood earned 125 total points
ID: 11791936
at the end of form1_onload use the key word end like this

Private Sub Form_Load()
    MsgBox "test"
   
    End
End Sub

hamood
0
 

Author Comment

by:siono4
ID: 11791989
Thats it, thanks
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Question has a verified solution.

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

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

792 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