473,395 Members | 1,905 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Strange Problem

im running the code below when a new item is selected within a combobox the
code runs fine but when it gets to me.close it crashes - it doesnt start the
next form just crashes (its not debugabble) it seems to be a problem with
the .net framwork - have i done something silly, or have i found a known
bug - if so is there a workaround?

Thanks in advance for your help

Mike Fellows

Private Sub ComboBox3_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles ComboBox3.SelectedIndexChanged
If Loading = False Then
TimeAddy = Me.ComboBox3.Text.ToString
SaveFactFind()

If Me.ComboBox3.Text = "36 Months or over" Then
Dim x As New TotalTimeAtAddress
x.ID = ID
x.show()
Else
Dim x As New PreviousAddresses
x.ID = ID
x.Show()
End If
Me.Close()
End If
End Sub
Nov 21 '05 #1
15 1345
How was the program started?

If you use
Application.Run(new MyForm)
, then the application will exit when the aforementioned form is closed.

If you use
Dim X as new MyForm
x.Show
Application.Run
, then the application will exit when all forms are closed.

--
Jonathan Allen
"Mike Fellows" <mi*************@equityhouse.NOSPAM.co.uk> wrote in message
news:4p********************@giganews.com...
im running the code below when a new item is selected within a combobox
the
code runs fine but when it gets to me.close it crashes - it doesnt start
the
next form just crashes (its not debugabble) it seems to be a problem with
the .net framwork - have i done something silly, or have i found a known
bug - if so is there a workaround?

Thanks in advance for your help

Mike Fellows

Private Sub ComboBox3_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles ComboBox3.SelectedIndexChanged
If Loading = False Then
TimeAddy = Me.ComboBox3.Text.ToString
SaveFactFind()

If Me.ComboBox3.Text = "36 Months or over" Then
Dim x As New TotalTimeAtAddress
x.ID = ID
x.show()
Else
Dim x As New PreviousAddresses
x.ID = ID
x.Show()
End If
Me.Close()
End If
End Sub

Nov 21 '05 #2
"Jonathan Allen" <x@x.x> schrieb
How was the program started?

If you use
Application.Run(new MyForm)
, then the application will exit when the aforementioned form is
closed.
If you use
Dim X as new MyForm
x.Show
Application.Run
, then the application will exit when all forms are closed.

No, it does not exit. You would have to call application.exitthread to exit
Application.Run.

Armin

Nov 21 '05 #3

"Armin Zingler" <az*******@freenet.de> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
"Jonathan Allen" <x@x.x> schrieb
How was the program started?

If you use
Application.Run(new MyForm)
, then the application will exit when the aforementioned form is
closed.
If you use
Dim X as new MyForm
x.Show
Application.Run
, then the application will exit when all forms are closed.

No, it does not exit. You would have to call application.exitthread to
exit Application.Run.

Armin


Yes, it does exit. The Application.Run(Form) overload adds an event handler
to the Closed event for the Form. When the Closed event it raised, the
event handler calls ExitThread to clean up the application.

MSDN Library Link:
ms-help://MS.MSDNQTR.2003FEB.1033/cpref/html/frlrfsystemwindowsformsapplicationclassruntopic3.h tm

This is explained in the above link :)

HTH,
Mythran

Nov 21 '05 #4
"Mythran" <ki********@hotmail.comREMOVETRAIL> schrieb

"Armin Zingler" <az*******@freenet.de> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
"Jonathan Allen" <x@x.x> schrieb
How was the program started?

If you use
Application.Run(new MyForm)
, then the application will exit when the aforementioned form is
closed.
If you use
Dim X as new MyForm
x.Show
Application.Run
, then the application will exit when all forms are closed.

No, it does not exit. You would have to call application.exitthread
to exit Application.Run.

Armin


Yes, it does exit. The Application.Run(Form) overload adds an event
handler to the Closed event for the Form. When the Closed event it
raised, the event handler calls ExitThread to clean up the
application.
MSDN Library Link:
ms-help://MS.MSDNQTR.2003FEB.1033/cpref/html/frlrfsystemwindowsformsapplicationclassruntopic3.h tm

This is explained in the above link :)

I was referring to the last statement I quoted. Application.run without
arguments does not exit when all forms are closed.

Armin

Nov 21 '05 #5
I was referring to the last statement I quoted. Application.run without
arguments does not exit when all forms are closed.

Armin


Ahh, my apologies, I got ahead of myself :)

Mythran

Nov 21 '05 #6
im using:

Dim x As New TotalTimeAtAddress
x.ID = ID
x.show()
me.close()
the problem is the code crashes out (not exits, crashes) before the new form
is even displayed

i understand that if all forms where closed then the program would exit -
but that isnt the case - it crashes out (but not when in debug mode)


"Jonathan Allen" <x@x.x> wrote in message
news:O7**************@TK2MSFTNGP15.phx.gbl...
How was the program started?

If you use
Application.Run(new MyForm)
, then the application will exit when the aforementioned form is closed.

If you use
Dim X as new MyForm
x.Show
Application.Run
, then the application will exit when all forms are closed.

--
Jonathan Allen
"Mike Fellows" <mi*************@equityhouse.NOSPAM.co.uk> wrote in message
news:4p********************@giganews.com...
im running the code below when a new item is selected within a combobox
the
code runs fine but when it gets to me.close it crashes - it doesnt start
the
next form just crashes (its not debugabble) it seems to be a problem with the .net framwork - have i done something silly, or have i found a known
bug - if so is there a workaround?

Thanks in advance for your help

Mike Fellows

Private Sub ComboBox3_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox3.SelectedIndexChanged
If Loading = False Then
TimeAddy = Me.ComboBox3.Text.ToString
SaveFactFind()

If Me.ComboBox3.Text = "36 Months or over" Then
Dim x As New TotalTimeAtAddress
x.ID = ID
x.show()
Else
Dim x As New PreviousAddresses
x.ID = ID
x.Show()
End If
Me.Close()
End If
End Sub


Nov 21 '05 #7
"Mike Fellows" <mi*************@equityhouse.NOSPAM.co.uk> schrieb
im using:

Dim x As New TotalTimeAtAddress
x.ID = ID
x.show()
me.close()
the problem is the code crashes out (not exits, crashes) before the
new form is even displayed

i understand that if all forms where closed then the program would
exit - but that isnt the case - it crashes out (but not when in debug
mode)


What does "crash" mean? Do you hear anything? ;-) Do you see a message? What
does it say?

Armin

Nov 21 '05 #8
ok i have worked out my problem, i just dont know how to fix it

on loading my form i do a loas of stuff to comboboxes (set values etc..)
while the form is loading i have a variable called loading that i set to
true.

so when i change a value of combobox and run some code i check that loading
= false
so that when setting values of comboboxes on form load it doesnt run this
code

looks somehting like this:

Private Sub ComboBox3_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles ComboBox3.SelectedIndexChanged
If Loading = False Then

do_stuff_here()

End If
End Sub

now if i add a me.close into the if loading = false statement so it looks
like this

If Loading = False Then

do_stuff_here()

me.close()
End If
when it eventully runs it does the do_stuff_here function then closes the
form
but then in debug mode it carries on after the me.close to the endif
statement
and crashes which has obvioulsy gone due to the me.close and crashes with
object reference not set to an instance of an object

i cant think of a solution to this and have no idea what to try, any help
would
be appreciated as im completely stuck now

"Mike Fellows" <mi*************@equityhouse.NOSPAM.co.uk> wrote in message
news:QN********************@giganews.com...
im using:

Dim x As New TotalTimeAtAddress
x.ID = ID
x.show()
me.close()
the problem is the code crashes out (not exits, crashes) before the new form is even displayed

i understand that if all forms where closed then the program would exit -
but that isnt the case - it crashes out (but not when in debug mode)


"Jonathan Allen" <x@x.x> wrote in message
news:O7**************@TK2MSFTNGP15.phx.gbl...
How was the program started?

If you use
Application.Run(new MyForm)
, then the application will exit when the aforementioned form is closed.

If you use
Dim X as new MyForm
x.Show
Application.Run
, then the application will exit when all forms are closed.

--
Jonathan Allen
"Mike Fellows" <mi*************@equityhouse.NOSPAM.co.uk> wrote in message
news:4p********************@giganews.com...
im running the code below when a new item is selected within a combobox the
code runs fine but when it gets to me.close it crashes - it doesnt start the
next form just crashes (its not debugabble) it seems to be a problem

with the .net framwork - have i done something silly, or have i found a known bug - if so is there a workaround?

Thanks in advance for your help

Mike Fellows

Private Sub ComboBox3_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox3.SelectedIndexChanged
If Loading = False Then
TimeAddy = Me.ComboBox3.Text.ToString
SaveFactFind()

If Me.ComboBox3.Text = "36 Months or over" Then
Dim x As New TotalTimeAtAddress
x.ID = ID
x.show()
Else
Dim x As New PreviousAddresses
x.ID = ID
x.Show()
End If
Me.Close()
End If
End Sub



Nov 21 '05 #9
Mike,

Everybody is asking the same to you.

I try it in my words. What is *me* it is obviously a form I can see from
your answers. However, how did you start this form.

In other words:
Is it a mainform that starts automaticly conform VBNet rules.
Did you creade an extra module to start that mainform
Is it maybe a form instanced in the mainform where the mainform is no owner.

etc etc.

Cor
Nov 21 '05 #10
apologies

me is justa windows form called from the main form it is started like:

dim x as new myform
myform.show

me = myform

thanks

"Cor Ligthert" <no************@planet.nl> wrote in message
news:uo**************@TK2MSFTNGP09.phx.gbl...
Mike,

Everybody is asking the same to you.

I try it in my words. What is *me* it is obviously a form I can see from
your answers. However, how did you start this form.

In other words:
Is it a mainform that starts automaticly conform VBNet rules.
Did you creade an extra module to start that mainform
Is it maybe a form instanced in the mainform where the mainform is no owner.
etc etc.

Cor

Nov 21 '05 #11
Mike,

Another questions,

What is the sense of this
If Loading = False Then

do_stuff_here()

me.close()
End If

You probably start another form in that do_stuff_here.

With me.close you try to delete all references that you have in your
program.
(To your mainform where it is instanced and to your subform that you
instanced)

My expection is that this kind of program should crash or give unpredictable
results which can be the reason that it crashes in the debugger..

However maybe have others better ideas. This is just a guess.

Cor
Nov 21 '05 #12
ok

how would you recommend that i open a new form that no longer requires the
current form

i need to populate a public variable within this form when it loads

to be honest i have always written the above like this

dim x as new mynewform()
x.publicvariable = variable
x.show
me.close()

never had any problems with the above until now

am i doing this wrong? im self taught in vb.net as i moved from c++ so i
have no idea if what i am doing is corrent

thanks

Mike
"Cor Ligthert" <no************@planet.nl> wrote in message
news:OM**************@tk2msftngp13.phx.gbl...
Mike,

Another questions,

What is the sense of this
If Loading = False Then

do_stuff_here()

me.close()
End If

You probably start another form in that do_stuff_here.

With me.close you try to delete all references that you have in your
program.
(To your mainform where it is instanced and to your subform that you
instanced)

My expection is that this kind of program should crash or give unpredictable results which can be the reason that it crashes in the debugger..

However maybe have others better ideas. This is just a guess.

Cor

Nov 21 '05 #13
Mike,

I tried it in a test like this. The result was be in my test that the form x
will be showed. (Not actualy because before it is painted it is already
removed because that in my test the parent was closed)

\\\
Label1.Text = x.ToString
If x < 10 Then
Dim frm As New Form12
frm.x = x + 1
frm.Show()
If x > 5 Then
Me.Close()
End If
End If
///

I would do your problem with events, and close the forms from the place I
have instanced them. However, that is my approach.

Cor

Nov 21 '05 #14
Thanks Cor

i sort of understand what your saying

but the way im doing it now is the way i have always done it, and i have
never ever had a problem before

all very strange

thanks though
"Cor Ligthert" <no************@planet.nl> wrote in message
news:OC**************@TK2MSFTNGP09.phx.gbl...
Mike,

I tried it in a test like this. The result was be in my test that the form x will be showed. (Not actualy because before it is painted it is already
removed because that in my test the parent was closed)

\\\
Label1.Text = x.ToString
If x < 10 Then
Dim frm As New Form12
frm.x = x + 1
frm.Show()
If x > 5 Then
Me.Close()
End If
End If
///

I would do your problem with events, and close the forms from the place I
have instanced them. However, that is my approach.

Cor

Nov 21 '05 #15
You mention that it crashes. Is there an error? If so what is it and
can you print out the stack trace?

Nov 21 '05 #16

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

Similar topics

5
by: Rob Ristroph | last post by:
Hi, It's pretty unhelpful to post "I have a huge piece of code that crashes in strange places, what's the problem?" but that's basically my problem and I really am at my wit's end. The piece...
2
by: Paul Drummond | last post by:
Hi all, I am developing software for Linux Redhat9 and I have noticed some very strange behaviour when throwing exceptions within a shared library. All our exceptions are derived from...
25
by: Neil Ginsberg | last post by:
I have a strange situation with my Access 2000 database. I have code in the database which has worked fine for years, and now all of a sudden doesn't work fine on one or two of my client's...
2
by: TB | last post by:
I am seeing a very strange problem as follows... I have a loop where a fair amount of processing is going on and near the top of the loop I access a class that has only static helper functions...
1
by: Sam Kong | last post by:
Hello! Recently I had a strange problem with Visual C# 2005 beta 1. When I ran(F5 key) a program, <#if DEBUG> statement was not working. It ran as RELEASE mode. So I had to manually define...
8
by: Spam Trap | last post by:
I am getting strange resizing problems when using an inherited form. Controls are moving themselves seemingly randomly, but reproducibly. "frmBase" is my base class (a windows form), and...
11
by: Martin Joergensen | last post by:
Hi, I've encountered a really, *really*, REALLY strange error :-) I have a for-loop and after 8 runs I get strange results...... I mean: A really strange result.... I'm calculating...
12
by: StephQ | last post by:
I have a class Bounds with two constructors: class Bounds { private: list<SegmentupperLinearSpline; // Upper bound. list<SegmentlowerLinearSpline; // Lower bound. ....
8
by: Dox33 | last post by:
I ran into a very strange behaviour of raw_input(). I hope somebody can tell me how to fix this. (Or is this a problem in the python source?) I will explain the problem by using 3 examples....
5
by: ioni | last post by:
Good day, fellows! I have a strange problem – at my site there is a flash strip, that loads data dynamically. It works fine (grabs data from the remote server and presents it), however in IE7...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.