Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2004-08-13
4
Medium Priority
?
603 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 500 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

971 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