Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Setting startup form

Posted on 2004-09-17
13
Medium Priority
?
279 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 200 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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 400 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

916 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