Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

vb.net auto instantiation (forms)

In VB.Net you can show a form without crete an object reference before... vb.net do it to you, but, that "feature" is generating many problems, eg:

Public Class Form1

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    Form3.Show()
End Sub
End Class

Public Class Form3
    Inherits System.Windows.Forms.Form
End Class

Is there any way to disable this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

No there is no way to disable that. It is called the default instance. If you don't want to use it - don't use it. I recommend creating a new instance.

Dim f3 As New Form3
f3.Show()

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...