Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2004-08-13
4
Medium Priority
?
602 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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 …
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

715 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