473,545 Members | 2,047 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Form Exit

Group,

i hope someone is able to help with this issue.

I'd like the form to exit after certain logic calculation... i tried the
me.dispose with in the Sub New() procedure, but it does not exit.

i passed the boolean true parameter to the Protected Overloads Overrides Sub
Dispose(ByVal disposing As Boolean), it does not do anything... i've included
a finalize procedure with no codes but still no go.

Please help.
Thanks in advance.
Ronin
Mar 28 '06 #1
10 2250
Hi,

Try "Me.Close() "...

Regards,

Cerebrus.

Mar 28 '06 #2
"Ronin" <Ro***@discussi ons.microsoft.c om> schrieb:
I'd like the form to exit after certain logic calculation... i tried the
me.dispose with in the Sub New() procedure, but it does not exit.


What do you mean with exit? To prevent the form from being initialized,
simply throw an exception.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Mar 28 '06 #3
"Cerebrus" <zo*****@sify.c om> schrieb:
Try "Me.Close() "...


This won't have any effect inside the form's constructor because the
construction of a form's instance doesn't make the form visible at all.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Mar 28 '06 #4
Where would i put it? with in the Sub New()?
i had a try catch block with in the Sub New():
If intC > 0 Then
MsgBox("A survey was already taken with your information. If
you feel this is an error, please e-mail St************* @mail.sprint.co m")
Try
Me.Dispose(True )
Catch ex As Exception
Me.Close()
End Try
End If

and it still loads the form.
Further suggestions?

Thanks in advance.
Ronin
"Herfried K. Wagner [MVP]" wrote:
"Ronin" <Ro***@discussi ons.microsoft.c om> schrieb:
I'd like the form to exit after certain logic calculation... i tried the
me.dispose with in the Sub New() procedure, but it does not exit.


What do you mean with exit? To prevent the form from being initialized,
simply throw an exception.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Mar 28 '06 #5
"Ronin" <Ro***@discussi ons.microsoft.c om> schrieb:
Where would i put it? with in the Sub New()?
i had a try catch block with in the Sub New():
If intC > 0 Then
MsgBox("A survey was already taken with your information.
If
you feel this is an error, please e-mail St************* @mail.sprint.co m")
Try
Me.Dispose(True )
Catch ex As Exception
Me.Close()
End Try
End If

and it still loads the form.


\\\
Public Class Form1
Public Sub New()
If...Then
Throw New Exception(...)
Else
...
End If
End Sub
...
End Class
....
Try
Dim f As New Form1()
Catch...
...
End Try
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Mar 28 '06 #6
Herfied,

The try/catch block statment seems to be out side the method body.
would i need to declare a separate class? if so, i'd like to be able to do
this without having to create a separate class in the form or class file.

Any help?
"Herfried K. Wagner [MVP]" wrote:
"Ronin" <Ro***@discussi ons.microsoft.c om> schrieb:
Where would i put it? with in the Sub New()?
i had a try catch block with in the Sub New():
If intC > 0 Then
MsgBox("A survey was already taken with your information.
If
you feel this is an error, please e-mail St************* @mail.sprint.co m")
Try
Me.Dispose(True )
Catch ex As Exception
Me.Close()
End Try
End If

and it still loads the form.


\\\
Public Class Form1
Public Sub New()
If...Then
Throw New Exception(...)
Else
...
End If
End Sub
...
End Class
....
Try
Dim f As New Form1()
Catch...
...
End Try
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Mar 28 '06 #7
"Ronin" <Ro***@discussi ons.microsoft.c om> schrieb:
The try/catch block statment seems to be out side the method body.
would i need to declare a separate class? if so, i'd like to be able to do
this without having to create a separate class in the form or class file.


You will have to place it where you are attempting to instantiate the form.
'Me.Close' and 'Me.Dispose' are rather useless because at the beginning of
the constructor the form is neither visible nor completely constructed.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Mar 28 '06 #8
Hi Ronin,
The try/catch block statment seems to be out side the method body.
would i need to declare a separate class? if so, i'd like to be able to do
this without having to create a separate class in the form or class file.
I think someone would be able to help you better, if you gave some
details about How your form is launched ? From which form is it
launched ?

Without that information, I can just suggest that you should add the
code that Herfried suggested, at the place where you launch the form.
(which would have to be in another form class, wouldn't it)

Herfried wrote :
This won't have any effect inside the form's constructor because the
construction of a form's instance doesn't make the form visible at all.


Thanks for the correction, Herfried, I didn't realize that Ronin wanted
to close his form in the Sub New itself. I thought he was looking for
the best place to close the form.

Regards,

Cerebrus.

Mar 29 '06 #9
The project/solution startup object is the actual form itself... i have no
class to launch/initialize anything else. The objective is to just create an
executable form file. The code within the form will then be use to connect to
a DB with DSN-less connection (string).

the form sub new code is as follows:
Public Sub New()
MyBase.New()
InitializeCompo nent()
With db
.Prop_User =
System.Security .Principal.Wind owsIdentity.Get Current.Name
.cnn.Open()
.Prop_String = 1
.rst.Open(.Prop _String, .cnn)
intC = .rst.RecordCoun t
.Close_DB(.rst)
If intC > 0 Then
MsgBox("Test already taken")
MsgBox("Form will now exit.", MsgBoxStyle.Inf ormation +
MsgBoxStyle.OKO nly, "Exiting")
Me.Dispose(True )
Throw New Exception(MsgBo x("Testing me",
MsgBoxStyle.OKO nly)) ' newly added code base on previous sugesstions
End If
End With
End Sub

But also tried adding the throw new exception within the Protected Overloads
Overrides Sub Dispose(ByVal disposing As Boolean) with the actual code
procedure below:

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
On Error GoTo ErrorHandler
If disposing Then
If Not (components Is Nothing) Then
components.Disp ose()
End If
End If
MyBase.Dispose( disposing)
ErrorHandler:
If Err.Number <> 0 Then
Throw New Exception("Test ing me")
End If
End Sub

hope this helps. Please advice of further suggestions.

Thanks in advance.
Ronin

"Cerebrus" wrote:
Hi Ronin,
The try/catch block statment seems to be out side the method body.
would i need to declare a separate class? if so, i'd like to be able to do
this without having to create a separate class in the form or class file.
I think someone would be able to help you better, if you gave some
details about How your form is launched ? From which form is it
launched ?

Without that information, I can just suggest that you should add the
code that Herfried suggested, at the place where you launch the form.
(which would have to be in another form class, wouldn't it)

Herfried wrote :
This won't have any effect inside the form's constructor because the
construction of a form's instance doesn't make the form visible at all.


Thanks for the correction, Herfried, I didn't realize that Ronin wanted
to close his form in the Sub New itself. I thought he was looking for
the best place to close the form.

Regards,

Cerebrus.

Mar 29 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
19316
by: Gregory A Greenman | last post by:
I'm trying to write a program in vb.net to automate filling out a series of forms on a website. There are three forms I need to fill out in sequence. The first one is urlencoded. My program is able to fill that one out just fine. The second form is multipart/form-data. Unfortunately, I haven't been able to fill that out in a way that makes...
14
10113
by: Abhi | last post by:
FYI: This message is for the benefit of MS Access Community. I found that this prblem has been encounterd by many but there is hardly any place where a complete solution is posted. So I thought I should give back to the community by posting our findings. Thanks you all for all your help till now by posting problems and their solutions. ...
8
12069
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the combobox. What is the solution? Thank you in advance.
11
18811
by: Jozef | last post by:
I have some old code that I use from the Access 95 Developers handbook. The code works very well, with the exception that it doesn't seem to recognize wide screens, and sizes tab controls so that they are too big and wind up covering up some of the fields on the main form. Is there any good code out there that works in a similar fashion...
5
73191
by: RAJ | last post by:
hi plz tell me how to know "how window is going to close"... i have to right code for X button of forms... plz telll me thanks bye
1
3389
by: dBNovice | last post by:
Please help! I have 3 forms: Task, Subtask, Elements. Elements is a subform of Subtask and Subtask is a subform of Task. I am able to navigate from Task to Subform to Element and from Element to Subtask to Task by pressing a button that makes each subform invisible/visible. The problem exists when I try to navigate from Element to Task to...
6
6915
by: San | last post by:
Hey, I need to create a form with several text boxes in which users type in key words, press a command button on the form and it opens a matching record. Thanking you in advance.
3
1833
mikeinspain
by: mikeinspain | last post by:
hi there.. I have a php form script that is pretty much there... I am however having a problem when I go to test the form. the mail comes through into my inbox displaying the information ok apart from the tel no.. field.. where it displays the entered email address. the code is below.. any help appreciated... :-) <?php if...
2
11852
by: Matuag | last post by:
Hi All, I want to create following command buttons on a Form which users can edit. Save ( Save Changes made) Cancel ( Undo data changes) Exit ( Close form) I am using Macros for each of these commands and they work perfect.
1
2828
by: igor221189 | last post by:
Hello everyone. I have Access 2000 database which holds student records in the school.It stores subject grades for each student.In the 'Student Grade Form', I would like to search student surname using a query rather than scrolling down through 100s of names.Also, I would like the results of the query search to show in the form automatically in...
0
7409
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7918
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7436
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
4958
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3446
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1897
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1022
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
715
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.