Solved

Setting startup form

Posted on 2004-09-17
13
231 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
Comment Utility
select Project->yourporject property
set start object to your startup form
0
 

Author Comment

by:gleznov
Comment Utility
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
Comment Utility
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
 

Author Comment

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

Expert Comment

by:planocz
Comment Utility
to jump to the next form.....

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

Expert Comment

by:tzxie2000
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 27

Expert Comment

by:planocz
Comment Utility
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
Comment Utility
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
Comment Utility
'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
Comment Utility
That code still only closes Form 1, but doesn't open form 2

JP
0
 

Author Comment

by:gleznov
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now