Solved

Setting startup form

Posted on 2004-09-17
13
251 Views
Last Modified: 2010-04-23
I know this is a really bad question.  I'm asking it anyway because I'm just not finding the exact answer I want.

I have about 12 forms created now.  I want to set one as the starting form and then move between forms by loading one and unloading the other.  How do I set the form to start with?

JP
0
Comment
Question by:gleznov
  • 6
  • 5
  • 2
13 Comments
 
LVL 5

Accepted Solution

by:
tzxie2000 earned 50 total points
ID: 12086021
select Project->yourporject property
set start object to your startup form
0
 

Author Comment

by:gleznov
ID: 12086150
Thanks - one more question for ya, I'll up the points  -  how do I now switch between forms?  In VB6 it was Unload Me, then Load frm  or something similar - how do I open one form?  Unload Me still works, but I don't see how to open the next form.  Thanks!

JP
0
 
LVL 27

Expert Comment

by:planocz
ID: 12086160
add this to your forms, It make a better entrance point for your forms

    '/ <summary>
    '/ The main entry point for the application.
    '/ </summary>
    <STAThread()> Public Shared Sub Main()
        Application.Run(New frmForm)             '<---- name of your form
    End Sub
0
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 

Author Comment

by:gleznov
ID: 12086165
or pardon, Me.Close() is what closes forms now.  
0
 
LVL 27

Expert Comment

by:planocz
ID: 12086189
to jump to the next form.....

            Dim objForm As New frmView   '<---- name of form
            objForm.ShowDialog()
0
 
LVL 5

Expert Comment

by:tzxie2000
ID: 12086205
in form1
some switch button write
me.hide()
form2.show()

in form2
some switch button write
me.hide()
form1.show()

create form1,form2 as a global variant
0
 
LVL 27

Expert Comment

by:planocz
ID: 12086210
Example: If you had a Exit or Cancel Button....

  Private Sub btnCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Me.Close()
    End Sub
0
 

Author Comment

by:gleznov
ID: 12086227
OK so far 50 points for each of you, I'm upping it one more time to ask this:

How can I close one form and open the next?  I can either:

close the form

or

open the new one

But I can't seem to do both...

Here's the code - there's a timer, after 2 seconds, it does this:

 Private Sub Timer1_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs) Handles Timer1.Elapsed
        Dim objForm As New frmLogin   '<---- name of form
        Me.Close()
        objForm.ShowDialog()

    End Sub

This only closes the form and it's over.

I've also tried:

        Dim objForm As New frmLogin   '<---- name of form
        objForm.ShowDialog()
        Me.Close()

And this doesn't close the form, but every 2 seconds it opens a new instance of frmLogin

JP
0
 
LVL 27

Expert Comment

by:planocz
ID: 12086274
'FORM 1

    '/ <summary>
    '/ The main entry point for the application.
    '/ </summary>
    <STAThread()> Public Shared Sub Main()
        Application.Run(New Form1)            
    End Sub

  Private Sub btnCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Me.Close()
    Dim objForm As New frmForm2   '<---- name of form
            objForm.ShowDialog()
   End Sub


'FORM 2

   '/ <summary>
    '/ The main entry point for the application.
    '/ </summary>
    <STAThread()> Public Shared Sub Main()
        Application.Run(New Form2)            
    End Sub

  Private Sub btnCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Me.Close()
    Dim objForm As New frmForm3   '<---- name of form
            objForm.ShowDialog()
   End Sub

0
 

Author Comment

by:gleznov
ID: 12086296
That code still only closes Form 1, but doesn't open form 2

JP
0
 

Author Comment

by:gleznov
ID: 12086361
Wait, do I need to add that <STAThread> stuff?

What's that do?

JP
0
 
LVL 27

Assisted Solution

by:planocz
planocz earned 100 total points
ID: 12086441
This is a sample app....

Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents btnExit As System.Windows.Forms.Button
    Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu
    Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem2 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem3 As System.Windows.Forms.MenuItem
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.btnExit = New System.Windows.Forms.Button
        Me.MainMenu1 = New System.Windows.Forms.MainMenu
        Me.MenuItem1 = New System.Windows.Forms.MenuItem
        Me.MenuItem2 = New System.Windows.Forms.MenuItem
        Me.MenuItem3 = New System.Windows.Forms.MenuItem
        Me.SuspendLayout()
        '
        'btnExit
        '
        Me.btnExit.Location = New System.Drawing.Point(192, 224)
        Me.btnExit.Name = "btnExit"
        Me.btnExit.Size = New System.Drawing.Size(60, 24)
        Me.btnExit.TabIndex = 0
        Me.btnExit.Text = "Next"
        '
        'MainMenu1
        '
        Me.MainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem1})
        '
        'MenuItem1
        '
        Me.MenuItem1.Index = 0
        Me.MenuItem1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem2, Me.MenuItem3})
        Me.MenuItem1.Text = "Forms"
        '
        'MenuItem2
        '
        Me.MenuItem2.Index = 0
        Me.MenuItem2.Text = "Forms2"
        '
        'MenuItem3
        '
        Me.MenuItem3.Index = 1
        Me.MenuItem3.Text = "Forms3"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(292, 273)
        Me.Controls.Add(Me.btnExit)
        Me.Menu = Me.MainMenu1
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.ResumeLayout(False)

    End Sub

#End Region
    '/ <summary>
    '/ The main entry point for the application.
    '/ </summary>
    <STAThread()> Public Shared Sub Main()
        Application.Run(New Form1)
    End Sub

    Private Sub btnExit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExit.Click
        Dim objForm As New frmCase   '<---- name of form
        objForm.ShowDialog()
        Me.Close()
    End Sub

    Private Sub Menu_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MenuItem2.Click, MenuItem3.Click
        Select Case sender.Text
            Case "Forms2"
                Dim objForm As New Form2   '<---- name of form
                objForm.ShowDialog()
            Case "Forms3"
                Dim objForm As New Form3   '<---- name of form
                objForm.ShowDialog()
        End Select

    End Sub

End Class
0
 
LVL 27

Expert Comment

by:planocz
ID: 12086482
if you want to see each form together then change this code piece per form....
from the above code

before..
  objForm.ShowDialog()
After..
  objForm.Show()
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question