Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old March 16th, 2004, 03:34 PM
Authorized User
Join Date: Aug 2003
Location: , , .
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default Form won't close

Is something wrong with my code? I'm working with Microsoft eMbedded Tools, and when I get to the second form it won't close when I hit the OK button. It should close everything, but it won't unload form2 and it is eating my memory.

Option Explicit
Private Sub Form_OKClick()
'unload everything and close program
Unload (Form1)
Unload (Form2)
Unload (Form3)
Unload (Form4)
End Sub

Private Sub Command1_Click()
' Save Data to invisible string
Form2.Text7 = "Barcode: " + Form2.Text1 + vbCrLf + "Serial Number: " + Form2.Text2 + vbCrLf + "Model: " + Form2.Text3 + vbCrLf + "date: " + Form2.Text4 + vbCrLf + "Owner: " + Form2.Text5 + vbCrLf + "Comments: " + Form2.Text6
Form2.Text1 = ""
Form2.Text2 = ""
Form2.Text3 = ""
Form2.Text4 = Date
Form2.Text5 = "ETL"
Form2.Text6 = ""
' Pop Up confirmation
MsgBox Form2.Text7, vbOKCancel
End Sub

Private Sub Command2_Click()
'Clear all data in fields
Form2.Text1 = ""
Form2.Text2 = ""
Form2.Text3 = ""
Form2.Text4 = Date
Form2.Text5 = "ETL"
Form2.Text6 = ""
'Close the form, pop up the new one
End Sub

Private Sub Form_Load()
Form2.Text4 = Date
Form2.Text5 = "ETL"
End Sub

  #2 (permalink)  
Old March 17th, 2004, 06:28 AM
Authorized User
Join Date: Mar 2004
Location: Leopoldsburg, , Belgium.
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to frankv25

I'm not shure but maybe you can try pointing to the form


  #3 (permalink)  
Old March 17th, 2004, 08:28 AM
Friend of Wrox
Join Date: Jun 2003
Location: McPherson, Kansas, USA.
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts

Where is this code located at in Form1, Form2, or FormX?

Can you give a sequence of events?

In the OKClick() method you have a command App.End does this end the application? If so are you saying the form is still loaded after the application has been terminated?

When you say it is eating your memory can you explain that better?

What is this "invisible string" you refer to? Are you using a textbox with the visible property set to false? Why do you not use a variable instead of a textbox?

It looks to me like you are referencing Form2 from another/other form(s) and using objects in Form2 when you should be using variables. If you need access to values throughout your application then try using a global variable. Just remember to always set the scope to the lowest level. It is not good practice to just create a bunch of global variables.

As long as you are referencing Form2 it is going to be loaded into memory.

Larry Asher

Similar Threads
Thread Thread Starter Forum Replies Last Post
Close all MdiChield form from open one form/Button salman .NET Framework 2.0 6 December 10th, 2007 03:21 AM
Close all MdiChield form from open one form salman .NET Framework 1.x 0 November 8th, 2007 12:32 AM
How To Close One Form And Show Another form Israr VS.NET 2002/2003 1 December 7th, 2004 12:30 PM
How Do I Close a Form When I Move to Another Form. flyingfox VB.NET 2002/2003 Basics 3 December 29th, 2003 08:56 AM
Cannot close the Form jkalinina C# 3 October 31st, 2003 05:02 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.