Solved

Setting startup form

Posted on 2004-09-17
13
271 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 

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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

631 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