Solved

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

Posted on 2004-08-13
4
570 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

708 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

15 Experts available now in Live!

Get 1:1 Help Now