Form showing then vanishing?

  • Thread starter Thread starter Adam Honek
  • Start date Start date
A

Adam Honek

Hello,

I have an app that starts in sub main()

I am making a new instance of a form so it can be displayed. It compiles
fine but when
the program is run the form shows up but then a split second later closes
itself.

Why is this?

Code below:

Public Sub main()
Dim MyNewForm As New AccountsForm

MyNewForm .Show()

End Sub

Thanks,

Adam
 
Adam Honek said:
I am making a new instance of a form so it can be displayed. It compiles
fine but when
the program is run the form shows up but then a split second later closes
itself.

Why is this?

Code below:

Public Sub main()
Dim MyNewForm As New AccountsForm

MyNewForm .Show()

Replace the line above with this one:

\\\
Application.Run(MyNewForm)
///
 
Adam,

Why you use sub main.

I have seen yesterday that Crouchie has the same idea as me about this.
(Can be that he was that much longer however I saw a message about this from
him yesterday)

AFAIK was Terry(Ohm) that already.

Cor
 
Hello,

I have an app that starts in sub main()

I am making a new instance of a form so it can be displayed. It compiles
fine but when
the program is run the form shows up but then a split second later closes
itself.

Why is this?

Code below:

Public Sub main()
Dim MyNewForm As New AccountsForm

MyNewForm .Show()

End Sub

Thanks,

Adam

Change it like this:

Public Sub Main ()
Application.Run (New AccountsForm)
End Sub
 
Adam,

Why you use sub main.

I have seen yesterday that Crouchie has the same idea as me about this.
(Can be that he was that much longer however I saw a message about this from
him yesterday)

AFAIK was Terry(Ohm) that already.

Cor

Is something wrong with using Sub Main? VB.NET trys to hide it - but, I
use it a lot for things like checking for a single instance, etc. Of
course, I do all my real programming in C# anyway...
 
Is something wrong with using Sub Main? VB.NET trys to hide it - but, I
use it a lot for things like checking for a single instance, etc. Of
course, I do all my real programming in C# anyway...

We are active in more newsgroups, therefore I know what language you are
using at the moment.

However why use archaic sentences, if there is something nice built in.
(You would probably have seen, that I am always asking to people why, who
want to translate, what they are used to do in the past, in a newer
languages).

My standard sample is from far in past, when somebody told that Cobol was
much slower than Fortran. He had a translated Sort from his Fortran program
in the same way in Cobol.

He did not know that there was a Sort method already from the first versions
built in as feature in the Cobol language.

(We know that this is bs. the compiler on a particular OS or in that time
computer makes the performance)

In C# it is not built in (and when not using a form in VBNet as well not).
However when you use a form, than why not use that built in feature.

Just my thought,

Cor
 
We are active in more newsgroups, therefore I know what language you are
using at the moment.

I hope you understand... I still like VB.NET - I just don't have much
call to use it anymore. My employer has standardized on C#. Plus,
since I've been messing around with Linux, I find Mono a convenient
method of staying with a familar language - and right now, VB.NET
doesn't work all that well on Mono (but it's getting better).
However why use archaic sentences, if there is something nice built in.
(You would probably have seen, that I am always asking to people why, who
want to translate, what they are used to do in the past, in a newer
languages).

My standard sample is from far in past, when somebody told that Cobol was
much slower than Fortran. He had a translated Sort from his Fortran program
in the same way in Cobol.

He did not know that there was a Sort method already from the first versions
built in as feature in the Cobol language.

(We know that this is bs. the compiler on a particular OS or in that time
computer makes the performance)

In C# it is not built in (and when not using a form in VBNet as well not).
However when you use a form, than why not use that built in feature.

Well, it actually is built in to Visual C#. When you create a windows forms
project in C#, a default Main is generated by Visual Studio - it just
doesn't hide it from you the way VB.NET does. I'm not saying to always use
Main by the way, but there are times when it is useful. I think of it as
another tool in the old toolbox :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top